@@ -7016,6 +7016,120 @@ TEST(pipeline_tsjs_receiver_parallel_keeps_service_edges) {
70167016 PASS();
70177017}
70187018
7019+ /* Route-registration CALLS edges (via=route_registration) out of the function
7020+ * `source_name`. */
7021+ static int route_registrations_from(cbm_store_t *s, const char *project, const char *source_name) {
7022+ cbm_edge_t *edges = NULL;
7023+ int edge_count = 0;
7024+ if (cbm_store_find_edges_by_type(s, project, "CALLS", &edges, &edge_count) != CBM_STORE_OK) {
7025+ return -1;
7026+ }
7027+ int matches = 0;
7028+ for (int i = 0; i < edge_count; i++) {
7029+ cbm_node_t source = {0};
7030+ int source_ok = cbm_store_find_node_by_id(s, edges[i].source_id, &source) == CBM_STORE_OK;
7031+ if (source_ok && source.name && strcmp(source.name, source_name) == 0 &&
7032+ edges[i].properties_json &&
7033+ strstr(edges[i].properties_json, "\"via\":\"route_registration\"")) {
7034+ matches++;
7035+ }
7036+ cbm_node_free_fields(&source);
7037+ }
7038+ if (edges) {
7039+ cbm_store_free_edges(edges, edge_count);
7040+ }
7041+ return matches;
7042+ }
7043+
7044+ /* `import Axios from "axios"` -- the default-import binding capitalized, a
7045+ * common convention -- must classify `Axios.get/post/delete(url)` as HTTP
7046+ * client calls exactly like `axios.*`. The library table matched only the
7047+ * lowercase id, so the calls fell through to the `.get`/`.post` route-suffix
7048+ * fallback and became route REGISTRATIONS: on
7049+ * microsoft/Game-Control-Puzzle-Event-Administration-Tools all 69 client
7050+ * calls masqueraded as server Routes. A real Express registration in the same
7051+ * project stays a registration. `fillers` > 0 forces the parallel resolver,
7052+ * 0 keeps the sequential one; both classify through the same table. */
7053+ static int capitalized_axios_case(int fillers) {
7054+ char tmp[256];
7055+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_axios_cap_XXXXXX");
7056+ if (!cbm_mkdtemp(tmp)) {
7057+ FAIL("tmpdir");
7058+ }
7059+
7060+ write_temp_file(tmp, "src/service.ts",
7061+ "import Axios from \"axios\";\n"
7062+ "export function getSettings(eventId: string) {\n"
7063+ " return Axios.get(`/api/admin/events/${eventId}/settings`);\n"
7064+ "}\n"
7065+ "export function addUser(eventId: string, participant: unknown) {\n"
7066+ " return Axios.post(`/api/admin/users/${eventId}`, participant);\n"
7067+ "}\n"
7068+ "export function removeUser(id: string) {\n"
7069+ " return Axios.delete(`/api/admin/users/${id}`);\n"
7070+ "}\n");
7071+ write_temp_file(tmp, "src/server.ts",
7072+ "function listUsers(req: unknown, res: unknown) {}\n"
7073+ "export function mount(router: any) {\n"
7074+ " router.get('/api/admin/users', listUsers);\n"
7075+ "}\n");
7076+ for (int i = 0; i < fillers; i++) {
7077+ char name[64];
7078+ char body[128];
7079+ snprintf(name, sizeof(name), "src/filler%d.ts", i);
7080+ snprintf(body, sizeof(body), "export function filler%d(): number {\n return %d;\n}\n", i,
7081+ i);
7082+ write_temp_file(tmp, name, body);
7083+ }
7084+
7085+ char *old_workers = getenv("CBM_WORKERS");
7086+ char *saved = old_workers ? strdup(old_workers) : NULL;
7087+ cbm_setenv("CBM_WORKERS", "4", 1);
7088+
7089+ char db_path[512];
7090+ snprintf(db_path, sizeof(db_path), "%s/axios_cap.db", tmp);
7091+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
7092+ ASSERT_NOT_NULL(p);
7093+ ASSERT_EQ(cbm_pipeline_run(p), 0);
7094+ const char *project = cbm_pipeline_project_name(p);
7095+
7096+ cbm_store_t *s = cbm_store_open_path(db_path);
7097+ ASSERT_NOT_NULL(s);
7098+
7099+ static const struct {
7100+ const char *caller;
7101+ const char *typed_route;
7102+ } client[] = {{"getSettings", "__route__GET__"},
7103+ {"addUser", "__route__POST__"},
7104+ {"removeUser", "__route__DELETE__"}};
7105+ for (size_t i = 0; i < sizeof(client) / sizeof(client[0]); i++) {
7106+ ASSERT_EQ(route_registrations_from(s, project, client[i].caller), 0);
7107+ ASSERT_EQ(http_calls_to_route(s, project, client[i].caller, client[i].typed_route), 1);
7108+ }
7109+ /* Control: the server-side registration is untouched. */
7110+ ASSERT_EQ(route_registrations_from(s, project, "mount"), 1);
7111+ ASSERT_EQ(http_calls_to_route(s, project, "mount", "__route__"), 0);
7112+
7113+ cbm_store_close(s);
7114+ cbm_pipeline_free(p);
7115+ if (saved) {
7116+ cbm_setenv("CBM_WORKERS", saved, 1);
7117+ free(saved);
7118+ } else {
7119+ cbm_unsetenv("CBM_WORKERS");
7120+ }
7121+ th_rmtree(tmp);
7122+ PASS();
7123+ }
7124+
7125+ TEST(pipeline_capitalized_axios_import_is_http_client) {
7126+ return capitalized_axios_case(52);
7127+ }
7128+
7129+ TEST(pipeline_capitalized_axios_import_is_http_client_sequential) {
7130+ return capitalized_axios_case(0);
7131+ }
7132+
70197133/* Python bare-call local-binding suppression, sequential path. The bare-call
70207134 * counterpart of the receiver guard above: `run` is a PARAMETER, so `run()`
70217135 * cannot be the module-level `run` and must not bind SatoriLive.run.
@@ -16482,6 +16596,8 @@ SUITE(pipeline) {
1648216596 RUN_TEST(pipeline_go_bare_ref_never_binds_field);
1648316597 RUN_TEST(pipeline_go_bare_ref_never_binds_field_parallel);
1648416598 RUN_TEST(pipeline_tsjs_receiver_parallel_keeps_service_edges);
16599+ RUN_TEST(pipeline_capitalized_axios_import_is_http_client);
16600+ RUN_TEST(pipeline_capitalized_axios_import_is_http_client_sequential);
1648516601 RUN_TEST(pipeline_python_receiver_parallel_suppresses_weak_method_edges);
1648616602 RUN_TEST(pipeline_python_bare_local_binding_suppresses_weak_edge);
1648716603 RUN_TEST(pipeline_python_bare_local_binding_parallel_suppresses_weak_edge);
0 commit comments