@@ -1824,6 +1824,157 @@ TEST(override_go_interface) {
18241824 PASS ();
18251825}
18261826
1827+ /* ══════════════════════════════════════════════════════════════════
1828+ * ROUTE REGISTRATION vs the #725 cross-language guard.
1829+ *
1830+ * The route classifier recognises a registration by its callee
1831+ * (`Route::get`, `$router->get`, `app.get`) plus a path-shaped first
1832+ * argument. The registry still resolves the callee's bare name first, and in
1833+ * a mixed-language repo with imports it binds `get` by suffix_match to a
1834+ * same-named definition in ANOTHER language (a JS `get`, a Python `get`).
1835+ * The #725 guard rightly refuses that binding — but it dropped the whole
1836+ * call, before either resolver reached the route classification, so every
1837+ * GET registration vanished while POST (no `post` definition to collide
1838+ * with) survived: krayin/laravel-crm minted 1 of its 127 GET routes.
1839+ * The guard must keep dropping the false CALLS edge; the registration must
1840+ * survive. Each fixture also carries calls the guard must still drop.
1841+ * ══════════════════════════════════════════════════════════════════ */
1842+
1843+ /* Index `files` (padded onto the parallel path when `parallel`), then require
1844+ * the exact Route-name set `routes` AND zero CALLS edges into any definition
1845+ * named `get`: every `get` in these fixtures lives in a different language
1846+ * than its would-be callers, so any such edge is the binding #725 refuses. */
1847+ static int et_xlang_routes (const EtFile * files , int nfiles , bool parallel , const char * * routes ) {
1848+ EtProj lp ;
1849+ cbm_store_t * store =
1850+ parallel ? et_index_parallel (& lp , files , nfiles ) : et_index_files (& lp , files , nfiles );
1851+ cbm_node_t * nodes = NULL ;
1852+ int node_count = 0 ;
1853+ int wanted = 0 ;
1854+ int ok = store != NULL ;
1855+ while (routes [wanted ]) {
1856+ wanted ++ ;
1857+ }
1858+ if (!store || cbm_store_find_nodes_by_label (store , lp .project , "Route" , & nodes , & node_count ) !=
1859+ CBM_STORE_OK ) {
1860+ ok = 0 ;
1861+ } else if (node_count != wanted ) {
1862+ ok = 0 ;
1863+ }
1864+ for (int wi = 0 ; wi < wanted ; wi ++ ) {
1865+ int hit = 0 ;
1866+ for (int ni = 0 ; ni < node_count ; ni ++ ) {
1867+ if (nodes [ni ].name && strcmp (nodes [ni ].name , routes [wi ]) == 0 ) {
1868+ hit = 1 ;
1869+ }
1870+ }
1871+ if (!hit ) {
1872+ fprintf (stderr , " [ET-XLANG] missing Route %s\n" , routes [wi ]);
1873+ ok = 0 ;
1874+ }
1875+ }
1876+ if (!ok ) {
1877+ fprintf (stderr , " [ET-XLANG] expected=%d actual=%d available:" , wanted , node_count );
1878+ for (int ni = 0 ; ni < node_count ; ni ++ ) {
1879+ fprintf (stderr , " %s" , nodes [ni ].name ? nodes [ni ].name : "<null>" );
1880+ }
1881+ fprintf (stderr , "\n" );
1882+ }
1883+ int false_calls = 0 ;
1884+ cbm_node_t * gets = NULL ;
1885+ int get_count = 0 ;
1886+ if (store &&
1887+ cbm_store_find_nodes_by_name (store , lp .project , "get" , & gets , & get_count ) == CBM_STORE_OK ) {
1888+ for (int gi = 0 ; gi < get_count ; gi ++ ) {
1889+ cbm_edge_t * in = NULL ;
1890+ int in_count = 0 ;
1891+ if (cbm_store_find_edges_by_target_type (store , gets [gi ].id , "CALLS" , & in , & in_count ) ==
1892+ CBM_STORE_OK ) {
1893+ false_calls += in_count ;
1894+ cbm_store_free_edges (in , in_count );
1895+ }
1896+ }
1897+ cbm_store_free_nodes (gets , get_count );
1898+ }
1899+ if (false_calls != 0 ) {
1900+ fprintf (stderr , " [ET-XLANG] %d cross-language CALLS into `get`\n" , false_calls );
1901+ ok = 0 ;
1902+ }
1903+ cbm_store_free_nodes (nodes , node_count );
1904+ et_cleanup (& lp , store );
1905+ return ok ;
1906+ }
1907+
1908+ /* Laravel: facade `Route::get` and `$router->get` beside two JS `get`
1909+ * definitions. Controls: POST is unchanged, and a bare PHP `get('/x')` (no
1910+ * route-registration callee) stays dropped — no Route, no CALLS into JS. */
1911+ static const EtFile et_xlang_laravel [] = {
1912+ {"app/Http/Controllers/LeadController.php" ,
1913+ "<?php\nnamespace App\\Http\\Controllers;\n\n"
1914+ "class LeadController\n{\n"
1915+ " public function index() { return []; }\n"
1916+ " public function store() { return []; }\n}\n" },
1917+ {"routes/web.php" ,
1918+ "<?php\nuse Illuminate\\Support\\Facades\\Route;\n"
1919+ "use App\\Http\\Controllers\\LeadController;\n\n"
1920+ "Route::get('/leads', [LeadController::class, 'index']);\n"
1921+ "Route::post('/leads/store', [LeadController::class, 'store']);\n"
1922+ "$router->get('/reports', [LeadController::class, 'index']);\n\n"
1923+ "function report_file() { return get('/files/report'); }\n" },
1924+ {"resources/js/http.js" , "export function get(url) {\n return url;\n}\n" },
1925+ {"resources/js/store.js" , "export class Store {\n get(key) {\n return key;\n }\n}\n" },
1926+ };
1927+ static const char * et_xlang_laravel_routes [] = {"/leads" , "/leads/store" , "/reports" , NULL };
1928+
1929+ TEST (routes_laravel_get_survives_xlang_guard ) {
1930+ ASSERT_TRUE (et_xlang_routes (et_xlang_laravel ,
1931+ (int )(sizeof (et_xlang_laravel ) / sizeof (et_xlang_laravel [0 ])),
1932+ false, et_xlang_laravel_routes ));
1933+ PASS ();
1934+ }
1935+
1936+ TEST (routes_laravel_get_survives_xlang_guard_parallel ) {
1937+ ASSERT_TRUE (et_xlang_routes (et_xlang_laravel ,
1938+ (int )(sizeof (et_xlang_laravel ) / sizeof (et_xlang_laravel [0 ])),
1939+ true, et_xlang_laravel_routes ));
1940+ PASS ();
1941+ }
1942+
1943+ /* Express: `app.get` beside two Python `get` definitions. Controls: POST is
1944+ * unchanged; a member `memo.get(key)` (route suffix, no path) and a bare
1945+ * `get('/cache/key')` stay dropped — no Route, no CALLS into Python. */
1946+ static const EtFile et_xlang_express [] = {
1947+ {"web/server.js" ,
1948+ "const express = require('express');\n"
1949+ "const { health } = require('./handlers');\n\n"
1950+ "const app = express();\n\n"
1951+ "app.get('/health', health);\n"
1952+ "app.post('/items', health);\n\n"
1953+ "function readCache(memo, key) {\n"
1954+ " return memo.get(key) || get('/cache/key');\n"
1955+ "}\n"
1956+ "module.exports = { readCache };\n" },
1957+ {"web/handlers.js" ,
1958+ "function health(req, res) {\n return res;\n}\nmodule.exports = { health };\n" },
1959+ {"tools/cache.py" , "def get(key):\n return key\n" },
1960+ {"tools/store.py" , "class Store:\n def get(self, key):\n return key\n" },
1961+ };
1962+ static const char * et_xlang_express_routes [] = {"/health" , "/items" , NULL };
1963+
1964+ TEST (routes_express_get_survives_xlang_guard ) {
1965+ ASSERT_TRUE (et_xlang_routes (et_xlang_express ,
1966+ (int )(sizeof (et_xlang_express ) / sizeof (et_xlang_express [0 ])),
1967+ false, et_xlang_express_routes ));
1968+ PASS ();
1969+ }
1970+
1971+ TEST (routes_express_get_survives_xlang_guard_parallel ) {
1972+ ASSERT_TRUE (et_xlang_routes (et_xlang_express ,
1973+ (int )(sizeof (et_xlang_express ) / sizeof (et_xlang_express [0 ])),
1974+ true, et_xlang_express_routes ));
1975+ PASS ();
1976+ }
1977+
18271978/* ══════════════════════════════════════════════════════════════════
18281979 * SUITE
18291980 * ══════════════════════════════════════════════════════════════════ */
@@ -1912,4 +2063,10 @@ SUITE(edge_types_probe) {
19122063
19132064 /* OVERRIDE — Go interface method override (parallel path) */
19142065 RUN_TEST (override_go_interface );
2066+
2067+ /* Route registration vs the #725 cross-language guard (both resolvers) */
2068+ RUN_TEST (routes_laravel_get_survives_xlang_guard );
2069+ RUN_TEST (routes_laravel_get_survives_xlang_guard_parallel );
2070+ RUN_TEST (routes_express_get_survives_xlang_guard );
2071+ RUN_TEST (routes_express_get_survives_xlang_guard_parallel );
19152072}
0 commit comments