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
feat(mcp): trace_path deploy mode; topology follows DEPLOYS
Martin Vogel932e5a9f57d1
diff --git a/README.md b/README.mdindex c98c179e4..3a65ad4d7 100644--- a/README.md+++ b/README.md@@ -233,8 +233,9 @@ The install script placed beside the binary is **reported, not deleted** — uni- `USAGE` — an identifier is used, but a unique callable target is not proven (including ambiguous or complex expressions)- `IMPORTS`, `DEFINES`, `IMPLEMENTS`, `INHERITS`- `HTTP_CALLS`, `ASYNC_CALLS` (cross-service)-- `SPAWNS` — the caller starts another program (`subprocess.run`, `exec.Command`, `posix_spawn`, `Process.Start`, a shell command or Make recipe running a program by path, ...); the target is a `Process` node named after the program, or `<dynamic>` when the program is not a literal. When a shell script, Make recipe, GitHub Actions step or Prow job runs a script of the repository (`./hack/x.sh`, `bash hack/x.sh`), the target is that script's `Module` (else its `File`), and edges from CI carry `ci` and `job`+- `SPAWNS` — the caller starts another program (`subprocess.run`, `exec.Command`, `posix_spawn`, `Process.Start`, a shell command or Make recipe running a program by path, ...); the target is a `Process` node named after the program, or `<dynamic>` when the program is not a literal. When a shell script, Make recipe, GitHub Actions step or Prow job runs a script of the repository (`./hack/x.sh`, `bash hack/x.sh`), the target is that script's `Module` (else its `File`); `make TARGET` (also `$(MAKE)`, `-C`, `-f`) targets the rule of that target, followed through included makefiles; edges from CI carry `ci` and `job`- `INFRA_MAPS` — a Kubernetes Service to each workload whose pod labels carry every `key: value` of the Service's selector, within one namespace+- `DEPLOYS` — what puts manifests, kustomizations or charts on a cluster, to what it puts there: a Flux Kustomization or Argo Application to the kustomizations / manifests / chart of its path, a Flux HelmRelease to its chart (`spec.chart` or `chartRef` → OCIRepository), a shell command or Make recipe (`kubectl apply -f/-k`, `kustomize build | kubectl apply`, `helm install/upgrade/template`), a Go installer loading a chart with the Helm SDK, a Terraform `helm_release`. A chart outside the repository is a shared external `Chart`; the edge says `via` (`flux`, `argo`, `helmrelease`, `kubectl`, `kustomize`, `helm`, `helm-sdk`, `terraform`, ...)- `DEPENDS_ON` — a Helm chart to the charts it declares (the local chart for a resolvable `file://` repository, otherwise an external `Chart`; the edge keeps `repository`), and a `go.mod` / `requirements.txt` file to an external `Package`- `EMITS`, `LISTENS_ON` (channels)- `DATA_FLOWS` with arg-to-param mapping + field access chains@@ -723,7 +724,7 @@ mode. `index_status` keeps describing the published graph and its freshness.| Tool | Description ||------|-------------|| `search_graph` | Structural, BM25, and semantic search. Page structural rows with `offset`/`limit` and ranked semantic rows independently with `semantic_offset`/`semantic_limit`. |-| `trace_path` | BFS traversal — who calls a function and what it calls (alias: `trace_call_path`). Depth 1-5. |+| `trace_path` | BFS traversal — who calls a function and what it calls (alias: `trace_call_path`). Depth 1-5. `mode`: `calls` (default), `data_flow`, `cross_service`, `topology` (Kubernetes objects, routes, controllers and what they deploy — start at a Resource or Route), `deploy` (what a CI job, script or Make rule runs and deploys — outbound from the job, inbound from a chart). || `detect_changes` | Map git diff to affected symbols + blast radius with risk classification. || `query_graph` | Execute Cypher-like graph queries (read-only). || `get_graph_schema` | Node/edge counts, relationship patterns, property definitions per label. Run this first. |diff --git a/src/mcp/mcp.c b/src/mcp/mcp.cindex 63b9e8a35..9453ba0fa 100644--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@ -622,9 +622,11 @@ static const tool_def_t TOOLS[] = {"\"cursor\":{\"type\":\"string\",\"description\":\"Pass next/next_cursor with traversal ""args unchanged; budget may increase.\"},""\"mode\":{"- "\"type\":\"string\",\"enum\":[\"calls\",\"data_flow\",\"cross_service\",\"topology\"],"+ "\"type\":\"string\",\"enum\":[\"calls\",\"data_flow\",\"cross_service\",\"topology\","+ "\"deploy\"],""\"default\":\"calls\",\"description\":\"calls, argument-aware data_flow, service edges, "- "or topology: infra objects, routes and controllers (start at a Resource or Route).\"},"+ "topology: infra objects, routes and controllers (start at a Resource or Route), or "+ "deploy: scripts, make targets and charts a CI job, script or rule runs and deploys.\"},""\"parameter_name\":{\"type\":\"string\",\"description\":\"data_flow parameter filter.\"},""\"edge_types\":{\"type\":\"array\",\"items\":{""\"type\":\"string\"}},\"risk_labels\":{\"type\":\"boolean\",\"default\":false,"@@ -8660,10 +8662,15 @@ static yyjson_doc *resolve_trace_edge_types(const char *args, const char *mode,"CROSS_HTTP_CALLS", "CROSS_ASYNC_CALLS", "CROSS_CHANNEL", "CROSS_GRPC_CALLS","CROSS_GRAPHQL_CALLS", "CROSS_TRPC_CALLS"};/* topology: traffic (INFRA_MAPS), object references (USAGE), ordering- * (DEPENDS_ON), controllers (HANDLES) and what an object declares- * (DEFINES: an Ingress's routes) */- static const char *mode_topology[] = {"INFRA_MAPS", "USAGE", "DEPENDS_ON", "HANDLES",- "DEFINES"};+ * (DEPENDS_ON), controllers (HANDLES), what an object declares+ * (DEFINES: an Ingress's routes) and what it deploys (DEPLOYS: a Flux+ * Kustomization's path, a HelmRelease's chart) */+ static const char *mode_topology[] = {"INFRA_MAPS", "USAGE", "DEPENDS_ON",+ "HANDLES", "DEFINES", "DEPLOYS"};+ /* deploy: what a CI job, script or Make rule starts (SPAWNS: scripts,+ * make targets, programs), calls (CALLS: shell functions) and puts on a+ * cluster (DEPLOYS) -- outbound from the job, inbound from a chart */+ static const char *mode_deploy[] = {"DEPLOYS", "SPAWNS", "CALLS"};*out_count = 0;@@ -8699,6 +8706,9 @@ static yyjson_doc *resolve_trace_edge_types(const char *args, const char *mode,} else if (mode && strcmp(mode, "topology") == 0) {defaults = mode_topology;n_defaults = (int)(sizeof(mode_topology) / sizeof(mode_topology[0]));+ } else if (mode && strcmp(mode, "deploy") == 0) {+ defaults = mode_deploy;+ n_defaults = (int)(sizeof(mode_deploy) / sizeof(mode_deploy[0]));}for (int i = 0; i < n_defaults; i++) {out_types[i] = defaults[i];diff --git a/tests/test_grammar_probe_f.c b/tests/test_grammar_probe_f.cindex fb1f1593c..9da45bc40 100644--- a/tests/test_grammar_probe_f.c+++ b/tests/test_grammar_probe_f.c@@ -1655,6 +1655,64 @@ TEST(probe_mcp_trace_topology) {PASS();}+/* trace_path mode=topology also follows DEPLOYS: from a Flux Kustomization+ * out to the kustomization its path applies. */+TEST(probe_mcp_trace_topology_follows_deploys) {+ static const GpfFile files[] = {+ {"clusters/sync.yaml",+ "apiVersion: kustomize.toolkit.fluxcd.io/v1\nkind: Kustomization\nmetadata:\n"+ " name: sync\n namespace: flux-system\nspec:\n path: ./apps\n"},+ {"apps/kustomization.yaml",+ "apiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n"+ "resources:\n - cm.yaml\n"},+ {"apps/cm.yaml", "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: settings\n"}};+ char *r = gpf_tool_on(files, 3, "trace_path",+ "{\"function_name\":\"Kustomization/sync\",\"project\":\"%s\","+ "\"direction\":\"outbound\",\"mode\":\"topology\",\"format\":\"json\"}");+ ASSERT_NOT_NULL(r);+ ASSERT_NOT_NULL(strstr(r, ".apps.kustomization\"")); /* the kustomization's Resource */+ free(r);+ PASS();+}++/* trace_path mode=deploy walks deploy chains: in from a chart to the shell+ * function that installs it (DEPLOYS), the script calling the function+ * (CALLS) and the CI job running the script (SPAWNS). The call graph mode+ * stops at the chart. */+TEST(probe_mcp_trace_deploy) {+ static const GpfFile files[] = {+ {"charts/web/Chart.yaml", "apiVersion: v2\nname: web-app\nversion: 0.1.0\n"},+ {"hack/deploy.sh", "#!/bin/sh\n"+ "cd \"$(dirname \"$0\")/..\"\n"+ "install_web() {\n"+ " helm upgrade --install web charts/web\n"+ "}\n"+ "install_web\n"},+ {".github/workflows/release.yml", "on: [push]\n"+ "jobs:\n"+ " ship:\n"+ " runs-on: ubuntu-latest\n"+ " steps:\n"+ " - run: ./hack/deploy.sh\n"}};+ char *r = gpf_tool_on(files, 3, "trace_path",+ "{\"function_name\":\"web-app\",\"project\":\"%s\","+ "\"direction\":\"inbound\",\"mode\":\"deploy\",\"depth\":4,"+ "\"format\":\"json\"}");+ ASSERT_NOT_NULL(r);+ ASSERT_NOT_NULL(strstr(r, "install_web"));+ ASSERT_NOT_NULL(strstr(r, ".hack\"")); /* the script's Module: hack.deploy */+ ASSERT_NOT_NULL(strstr(r, ".github.workflows\"")); /* the workflow's Module: release */+ ASSERT_NOT_NULL(strstr(r, "\"release\""));+ free(r);+ r = gpf_tool_on(files, 3, "trace_path",+ "{\"function_name\":\"web-app\",\"project\":\"%s\","+ "\"direction\":\"inbound\",\"format\":\"json\"}");+ ASSERT_NOT_NULL(r);+ ASSERT_NULL(strstr(r, "install_web"));+ free(r);+ PASS();+}+/* ── DEPLOYS (Phase 3) ──────────────────────────────────────────────── *//* A Flux Kustomization deploys what its path applies: the outermost@@ -4083,6 +4141,8 @@ SUITE(grammar_probe_f) {RUN_TEST(probe_k8s_ingress_and_httproute_expose_routes);RUN_TEST(probe_mcp_search_filters_kind_and_namespace);RUN_TEST(probe_mcp_trace_topology);+ RUN_TEST(probe_mcp_trace_topology_follows_deploys);+ RUN_TEST(probe_mcp_trace_deploy);RUN_TEST(probe_gitops_objects_deploy_their_units);RUN_TEST(probe_shell_kubectl_deploys_what_it_applies);RUN_TEST(probe_shell_helm_deploys_its_chart);