@@ -15040,6 +15040,102 @@ TEST(pipeline_angular_http_client_typed_sequential) {
1504015040 return angular_http_client_typed_case(0);
1504115041}
1504215042
15043+ /* #2768: the arg-URL heuristic (detect_url_in_args, via=arg_url) covers calls
15044+ * no service pattern knows, and it now types the edge with the verb the callee
15045+ * names instead of minting a method-less __route__ANY__ route. Two wrapper
15046+ * shapes reach it on the parallel resolver:
15047+ * - a project wrapper method whose verb is not a route-registration suffix
15048+ * (`this.api.head('/items/health')`, `.options(...)`), resolved to the
15049+ * project method, so the URL may be the first argument;
15050+ * - a route-verb wrapper (`.get`) whose URL is not route shaped for the
15051+ * registration reader: here a keyword it does not read as a path
15052+ * (`self.session.get(resource="/items/list")`).
15053+ * Parallel only: the sequential resolver has no arg-URL heuristic (#2848). */
15054+ TEST(pipeline_arg_url_wrapper_call_typed_with_verb_issue2768) {
15055+ char tmp[256];
15056+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_arg_url_verb_XXXXXX");
15057+ if (!cbm_mkdtemp(tmp)) {
15058+ FAIL("tmpdir");
15059+ }
15060+ write_temp_file(tmp, "src/items.api.ts",
15061+ "export class ItemsApi {\n"
15062+ " head(path: string): Promise<Response> {\n"
15063+ " return fetch(path, { method: 'HEAD' });\n"
15064+ " }\n"
15065+ " options(path: string): Promise<Response> {\n"
15066+ " return fetch(path, { method: 'OPTIONS' });\n"
15067+ " }\n"
15068+ "}\n");
15069+ write_temp_file(tmp, "src/item.service.ts",
15070+ "import { ItemsApi } from './items.api';\n"
15071+ "export class ItemService {\n"
15072+ " constructor(private readonly api: ItemsApi) {}\n"
15073+ " pingItems() {\n"
15074+ " return this.api.head('/items/health');\n"
15075+ " }\n"
15076+ " probeItems() {\n"
15077+ " return this.api.options('/items/list');\n"
15078+ " }\n"
15079+ "}\n");
15080+ write_temp_file(tmp, "src/reader.py",
15081+ "class ItemsSession:\n"
15082+ " def get(self, *args, **kwargs):\n"
15083+ " return args\n"
15084+ "\n"
15085+ "class Reader:\n"
15086+ " def __init__(self):\n"
15087+ " self.session = ItemsSession()\n"
15088+ "\n"
15089+ " def read_items(self):\n"
15090+ " return self.session.get(resource=\"/items/list\")\n");
15091+ for (int i = 0; i < 52; i++) {
15092+ char name[64];
15093+ char body[128];
15094+ snprintf(name, sizeof(name), "src/filler%d.ts", i);
15095+ snprintf(body, sizeof(body), "export function filler%d(): number {\n return %d;\n}\n", i,
15096+ i);
15097+ write_temp_file(tmp, name, body);
15098+ }
15099+ char *old_workers = getenv("CBM_WORKERS");
15100+ char *saved = old_workers ? strdup(old_workers) : NULL;
15101+ cbm_setenv("CBM_WORKERS", "4", 1);
15102+ char db_path[512];
15103+ snprintf(db_path, sizeof(db_path), "%s/arg_url_verb.db", tmp);
15104+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
15105+ ASSERT_NOT_NULL(p);
15106+ ASSERT_EQ(cbm_pipeline_run(p), 0);
15107+ const char *project = cbm_pipeline_project_name(p);
15108+ cbm_store_t *s = cbm_store_open_path(db_path);
15109+ ASSERT_NOT_NULL(s);
15110+
15111+ static const struct {
15112+ const char *caller;
15113+ const char *typed_route;
15114+ } wrapped[] = {{"pingItems", "__route__HEAD__/items/health"},
15115+ {"probeItems", "__route__OPTIONS__/items/list"},
15116+ {"read_items", "__route__GET__/items/list"}};
15117+ for (size_t i = 0; i < sizeof(wrapped) / sizeof(wrapped[0]); i++) {
15118+ /* The edge carries the callee's verb ... */
15119+ ASSERT_EQ(http_calls_to_route(s, project, wrapped[i].caller, wrapped[i].typed_route), 1);
15120+ /* ... and is the call site's only HTTP_CALLS edge: no ANY twin. */
15121+ ASSERT_EQ(http_calls_to_route(s, project, wrapped[i].caller, "__route__ANY__"), 0);
15122+ ASSERT_EQ(http_calls_to_route(s, project, wrapped[i].caller, "__route__"), 1);
15123+ }
15124+ /* Not a route registration */
15125+ ASSERT_EQ(cbm_store_count_edges_by_type(s, project, "HANDLES"), 0);
15126+
15127+ cbm_store_close(s);
15128+ cbm_pipeline_free(p);
15129+ if (saved) {
15130+ cbm_setenv("CBM_WORKERS", saved, 1);
15131+ free(saved);
15132+ } else {
15133+ cbm_unsetenv("CBM_WORKERS");
15134+ }
15135+ th_rmtree(tmp);
15136+ PASS();
15137+ }
15138+
1504315139/* #706 / #1147 end to end: a URL composed from module constants reaches the
1504415140 * HTTP classifier, so the client call forms an HTTP_CALLS edge. Python
1504515141 * `API_URL = API_BASE_URL + "/orders/create"` (env-derived base, literal path
@@ -29486,6 +29582,7 @@ SUITE(pipeline) {
2948629582 RUN_TEST(pipeline_typed_http_call_has_no_arg_url_twin_sequential);
2948729583 RUN_TEST(pipeline_angular_http_client_typed_parallel);
2948829584 RUN_TEST(pipeline_angular_http_client_typed_sequential);
29585+ RUN_TEST(pipeline_arg_url_wrapper_call_typed_with_verb_issue2768);
2948929586 RUN_TEST(pipeline_url_constant_folding_http_calls_issue706_1147);
2949029587 RUN_TEST(pipeline_folded_topics_preserve_identity_sequential_parallel);
2949129588 RUN_TEST(pipeline_relative_folded_wrapper_url_candidates);
0 commit comments