Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(routes): only an exposed-endpoint key turns a config URL into a Route
Martin Vogel0dac32ad0d0f
diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.cindex 179a5c981..36846c819 100644--- a/src/pipeline/pipeline.c+++ b/src/pipeline/pipeline.c@@ -1640,21 +1640,32 @@ static bool is_ci_tooling_config(const char *fp) {return false;}-/* True when a YAML key path denotes an UPSTREAM dependency, CONFIG value, or- * HEALTHCHECK target rather than an endpoint this service exposes. Such URLs- * (auth JWKS, downstream service base URLs, package-registry URLs, healthcheck- * curl targets) are NOT routes the service serves and must not mint Route nodes- * (#521). Exposed-endpoint keys (push_endpoint, post_url, callback, webhook)- * are intentionally absent here so they still produce infra Route nodes. */-static bool is_upstream_config_key(const char *key_path) {+/* True when a config key names an endpoint THIS service exposes -- a URL other+ * systems call on it: a push subscription's endpoint, a post/callback/webhook+ * URL. Only such keys mint infra Route nodes. Every other config URL is a+ * reference: an upstream dependency, a registry or repository, a docs or+ * runbook link, a changelog's pull-request link, a kubeconfig server. A deny+ * list of those (#521) could not keep up: in 17 infra repositories almost+ * every infra Route came from such a key (deckhouse: 6,240 `pull_request`+ * links). The leaf key decides, compared ignoring case, `_` and `-`. */+static bool is_exposed_endpoint_key(const char *key_path) {if (!key_path) {- /* No key context (e.g. flat string) — keep prior behaviour and mint. */return false;}- static const char *const deny[] = {"jwks", "registry", "registries", "healthcheck",- "upstream", "_service_url", "auth", NULL};- for (int i = 0; deny[i]; i++) {- if (strstr(key_path, deny[i]) != NULL) {+ const char *leaf = strrchr(key_path, '.');+ leaf = leaf ? leaf + SKIP_ONE : key_path;+ char norm[CBM_SZ_64];+ size_t n = 0;+ for (const char *p = leaf; *p && n + 1 < sizeof(norm); p++) {+ if (*p != '_' && *p != '-') {+ norm[n++] = (char)tolower((unsigned char)*p);+ }+ }+ norm[n] = '\0';+ static const char *const endpoints[] = {"pushendpoint", "posturl", "callback", "callbackurl",+ "webhook", "webhookurl", NULL};+ for (int i = 0; endpoints[i]; i++) {+ if (strcmp(norm, endpoints[i]) == 0) {return true;}}@@ -1666,8 +1677,8 @@ static void try_upsert_infra_route(cbm_gbuf_t *gbuf, const CBMStringRef *sr, conif (sr->kind != CBM_STRREF_URL || !sr->value || !strstr(sr->value, "://")) {return;}- /* Skip upstream/config/healthcheck URLs — they are not exposed routes (#521). */- if (is_upstream_config_key(sr->key_path)) {+ /* Only an endpoint this service exposes is a route it serves (#521). */+ if (!is_exposed_endpoint_key(sr->key_path)) {return;}char route_qn[CBM_ROUTE_QN_SIZE];@@ -1685,8 +1696,8 @@ static void try_upsert_infra_route(cbm_gbuf_t *gbuf, const CBMStringRef *sr, con/* A URL string_ref that does NOT denote a route the service serves: a value* containing whitespace is a command/sentence with an embedded URL (e.g. a* Docker healthcheck `curl --fail http://... || exit 1`); a NULL key_path is a- * context-less/duplicate ref; an upstream/config/healthcheck key is an external- * dependency, not an exposed route. (#521) */+ * context-less/duplicate ref; any key but an exposed-endpoint key is a+ * reference, not an exposed route. (#521) */static bool route_sr_denied(const CBMStringRef *sr) {if (!sr->value || strchr(sr->value, ' ')) {return true;@@ -1694,7 +1705,7 @@ static bool route_sr_denied(const CBMStringRef *sr) {if (!sr->key_path) {return true;}- return is_upstream_config_key(sr->key_path);+ return !is_exposed_endpoint_key(sr->key_path);}static void cbm_pipeline_extract_infra_routes(const cbm_pipeline_ctx_t *ctx, cbm_gbuf_t *gbuf,diff --git a/tests/test_lang_contract.c b/tests/test_lang_contract.cindex 6b3824df6..73d8c5575 100644--- a/tests/test_lang_contract.c+++ b/tests/test_lang_contract.c@@ -1553,6 +1553,54 @@ TEST(contract_edge_infra_routes_from_deploy_configs_still_minted) {PASS();}+/* A config URL becomes an infra Route only under a key that names an endpoint+ * this service exposes. Reference links are not: across 17 infra repositories+ * the infra Routes were changelog `pull_request` links (deckhouse 6,240),+ * alert `runbook_url`s, chart `home`/`source`, kubeconfig `server`s, Argo+ * `repoURL`s and docs `link`s -- and one root handler took all of them. */+TEST(contract_edge_no_infra_routes_from_reference_links) {+ LangProj lp;+ static const LangFile f[] = {+ {"CHANGELOG/v1.29.yml", "candi:\n"+ " fixes:\n"+ " - summary: fix a race\n"+ " pull_request: https://github.com/org/repo/pull/1234\n"},+ {"modules/cni/oss.yaml", "- name: Cilium\n"+ " link: https://github.com/cilium/cilium\n"},+ {"charts/app/alerts.yaml", "groups:\n"+ " - name: app\n"+ " rules:\n"+ " - alert: Down\n"+ " annotations:\n"+ " runbook_url: https://runbooks.example.io/down\n"},+ {"apps/app.yaml", "spec:\n"+ " source:\n"+ " repoURL: https://charts.example.io/stable\n"+ " home: https://app.example.io\n"}};+ cbm_store_t *store = lang_index_files(&lp, f, 4);+ ASSERT_NOT_NULL(store);+ ASSERT_EQ(count_infra_routes_matching(store, lp.project, "https://"), 0);+ lang_cleanup(&lp, store);+ PASS();+}++/* The endpoint keys keep minting in their camelCase / _url spellings. */+TEST(contract_edge_infra_routes_from_endpoint_key_spellings) {+ LangProj lp;+ static const LangFile f[] = {+ {"pubsub.yaml", "subscriptions:\n"+ " - name: orders\n"+ " pushEndpoint: https://orders.internal.example/push\n"},+ {"hooks.yaml", "payments:\n"+ " callbackUrl: https://pay.internal.example/callback\n"}};+ cbm_store_t *store = lang_index_files(&lp, f, 2);+ ASSERT_NOT_NULL(store);+ ASSERT_TRUE(count_infra_routes_matching(store, lp.project, "orders.internal.example") >= 1);+ ASSERT_TRUE(count_infra_routes_matching(store, lp.project, "pay.internal.example") >= 1);+ lang_cleanup(&lp, store);+ PASS();+}+/* True if some CALLS edge's TARGET node carries `label` and a QN ending with* `qn_suffix` — i.e. the call resolved to that specific definition. */static int calls_edge_targets(cbm_store_t *store, const char *project, const char *label,@@ -1897,6 +1945,8 @@ SUITE(lang_contract) {RUN_TEST(contract_edge_python_aliased_import_call_resolves_issue988);RUN_TEST(contract_edge_no_infra_routes_from_ci_configs_issue999);RUN_TEST(contract_edge_infra_routes_from_deploy_configs_still_minted);+ RUN_TEST(contract_edge_no_infra_routes_from_reference_links);+ RUN_TEST(contract_edge_infra_routes_from_endpoint_key_spellings);RUN_TEST(contract_edge_commonjs_require_call_resolves_issue871);RUN_TEST(contract_edge_depends_on);RUN_TEST(contract_edge_parallel_service_edges);