Skip to content

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.

Merge remote-tracking branch 'origin/main' into HEAD

Martin Vogel0ec24787fa7c
diff --cc tests/test_lang_contract.c
index 087ac0040,218978c14..3ce639ded
--- a/tests/test_lang_contract.c
+++ b/tests/test_lang_contract.c
@@@ -1207,41 -1207,100 +1207,135 @@@ TEST(contract_edge_imports_alias_resolv
PASS();
}
+/* True if a CALLS edge exists whose source QN ends with `src_suffix` and
+ * target QN ends with `tgt_suffix`. */
+static int calls_edge_between(cbm_store_t *store, const char *project, const char *src_suffix,
+ const char *tgt_suffix) {
+ cbm_edge_t *edges = NULL;
+ int n = 0;
+ if (cbm_store_find_edges_by_type(store, project, "CALLS", &edges, &n) != CBM_STORE_OK)
+ return 0;
+ int found = 0;
+ size_t ssl = strlen(src_suffix);
+ size_t tsl = strlen(tgt_suffix);
+ for (int i = 0; i < n && !found; i++) {
+ cbm_node_t s, t;
+ if (cbm_store_find_node_by_id(store, edges[i].source_id, &s) != CBM_STORE_OK)
+ continue;
+ if (cbm_store_find_node_by_id(store, edges[i].target_id, &t) != CBM_STORE_OK) {
+ cbm_node_free_fields(&s);
+ continue;
+ }
+ const char *sq = s.qualified_name;
+ const char *tq = t.qualified_name;
+ if (sq && tq) {
+ size_t sql = strlen(sq);
+ size_t tql = strlen(tq);
+ if (sql >= ssl && strcmp(sq + sql - ssl, src_suffix) == 0 && tql >= tsl &&
+ strcmp(tq + tql - tsl, tgt_suffix) == 0)
+ found = 1;
+ }
+ cbm_node_free_fields(&s);
+ cbm_node_free_fields(&t);
+ }
+ cbm_store_free_edges(edges, n);
+ return found;
+}
+
+ /* #999: URLs in CI/tooling configs (.pre-commit-config.yaml, .github/
+ * workflows) are repository references for TOOLING, not endpoints this
+ * service exposes. They must not mint __route__infra__ Route nodes — the
+ * route matcher's root-service heuristic otherwise attaches every handler
+ * of an ambiguous "/" route to each junk URL (HANDLES churn on plain
+ * pallets/flask). */
+ static int count_infra_routes_matching(cbm_store_t *store, const char *project,
+ const char *substr) {
+ cbm_node_t *nodes = NULL;
+ int count = 0;
+ if (cbm_store_find_nodes_by_label(store, project, "Route", &nodes, &count) != CBM_STORE_OK)
+ return -1;
+ int hits = 0;
+ for (int i = 0; i < count; i++) {
+ const char *qn = nodes[i].qualified_name;
+ if (qn && strncmp(qn, "__route__infra__", (sizeof("__route__infra__") - 1)) == 0 &&
+ strstr(qn, substr))
+ hits++;
+ }
+ cbm_store_free_nodes(nodes, count);
+ return hits;
+ }
+
+ TEST(contract_edge_no_infra_routes_from_ci_configs_issue999) {
+ LangProj lp;
+ static const LangFile f[] = {
+ {"app.py", "from flask import Flask\n"
+ "app = Flask(__name__)\n"
+ "\n"
+ "@app.route(\"/\")\n"
+ "def index():\n"
+ " return \"hi\"\n"
+ "\n"
+ "@app.route(\"/auth/login\")\n"
+ "def login():\n"
+ " return \"login\"\n"},
+ {".pre-commit-config.yaml", "repos:\n"
+ " - repo: https://github.com/astral-sh/ruff-pre-commit\n"
+ " rev: v0.1.0\n"
+ " hooks:\n"
+ " - id: ruff\n"
+ " - repo: https://github.com/pre-commit/pre-commit-hooks\n"
+ " rev: v4.5.0\n"
+ " hooks:\n"
+ " - id: trailing-whitespace\n"},
+ {".github/workflows/ci.yml", "name: CI\n"
+ "on: [push]\n"
+ "jobs:\n"
+ " build:\n"
+ " runs-on: ubuntu-latest\n"
+ " steps:\n"
+ " - uses: actions/checkout@v4\n"
+ " - run: curl https://coverage.example.io/upload\n"}};
+ cbm_store_t *store = lang_index_files(&lp, f, 3);
+ ASSERT_NOT_NULL(store);
+ /* No tooling URL may materialize as an infra Route node. */
+ int gh_routes = count_infra_routes_matching(store, lp.project, "github.com");
+ int wf_routes = count_infra_routes_matching(store, lp.project, "coverage.example.io");
+ if (gh_routes != 0 || wf_routes != 0) {
+ fprintf(stderr,
+ " [999] FAIL infra routes from CI configs: github.com=%d workflows=%d "
+ "(expected 0/0)\n",
+ gh_routes, wf_routes);
+ }
+ ASSERT_EQ(gh_routes, 0);
+ ASSERT_EQ(wf_routes, 0);
+ lang_cleanup(&lp, store);
+ PASS();
+ }
+
+ /* #999 inverse guard: genuine infra endpoint URLs (Cloud Scheduler push
+ * targets and similar deployment configs) must STILL mint infra Route
+ * nodes — the CI/tooling deny must be file-scoped, not a blanket URL kill. */
+ TEST(contract_edge_infra_routes_from_deploy_configs_still_minted) {
+ LangProj lp;
+ static const LangFile f[] = {
+ {"scheduler.yaml",
+ "jobs:\n"
+ " - name: nightly-sync\n"
+ " schedule: \"0 3 * * *\"\n"
+ " push_endpoint: https://sync.internal.example/api/v1/sync\n"}};
+ cbm_store_t *store = lang_index_files(&lp, f, 1);
+ ASSERT_NOT_NULL(store);
+ int routes = count_infra_routes_matching(store, lp.project, "sync.internal.example");
+ if (routes < 1) {
+ fprintf(stderr, " [999] FAIL deploy-config endpoint minted %d infra routes "
+ "(expected >=1)\n",
+ routes);
+ }
+ ASSERT_TRUE(routes >= 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,
@@@ -1562,7 -1572,8 +1656,9 @@@ SUITE(lang_contract)
RUN_TEST(contract_edge_workspaces_imports_issue408);
RUN_TEST(contract_edge_imports_alias_no_phantom_folder_edge_issue767);
RUN_TEST(contract_edge_imports_alias_resolves_real_file_issue767);
+ 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_commonjs_require_call_resolves_issue871);
RUN_TEST(contract_edge_depends_on);
RUN_TEST(contract_edge_parallel_service_edges);