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(infra): new Helm and kustomize code allocates through the memory core
Martin Vogel48278d5117ad
diff --git a/scripts/memory-core-baseline.txt b/scripts/memory-core-baseline.txtindex 32c4a89db..b277da976 100644--- a/scripts/memory-core-baseline.txt+++ b/scripts/memory-core-baseline.txt@@ -70,7 +70,7 @@ src/pipeline/pass_infrascan.c 2src/pipeline/pass_k8s.c 6src/pipeline/pass_lsp_cross.c 49src/pipeline/pass_parallel.c 31-src/pipeline/pass_pkgmap.c 82+src/pipeline/pass_pkgmap.c 81src/pipeline/pass_semantic.c 3src/pipeline/pass_tests.c 3src/pipeline/pass_usages.c 4diff --git a/src/pipeline/pass_k8s.c b/src/pipeline/pass_k8s.cindex 34a6aeb76..040cb1688 100644--- a/src/pipeline/pass_k8s.c+++ b/src/pipeline/pass_k8s.c@@ -646,39 +646,47 @@ static bool k8s_external_dep(cbm_pipeline_ctx_t *ctx, int64_t chart_id, const chreturn true;}+/* QN of the chart a relative `file://` directory names, core-owned; NULL for+ * an absolute path (it names the build host, not this repo). */+static char *k8s_local_chart_qn(const char *project, const char *chart_rel, const char *dir) {+ if (!dir[0] || dir[0] == '/') {+ return NULL;+ }+ char rel[CBM_HELM_REPO_MAX + K8S_SLEN("./") + K8S_SLEN("/Chart.yaml")];+ snprintf(rel, sizeof(rel), "%s%s/Chart.yaml", strncmp(dir, "../", 3) == 0 ? "" : "./", dir);+ /* fqn.c hands out libc-allocated strings: copy into the core, release them. */+ char *path = cbm_pipeline_resolve_relative_import(chart_rel, rel);+ char *qn = path ? cbm_infra_qn(project, path, "helm-chart", NULL) : NULL;+ free(path);+ char *owned = qn ? cbm_mem_strdup(CBM_MEM_CLASS_OTHER, qn) : NULL;+ free(qn);+ return owned;+}+static void k8s_local_deps_push(k8s_local_deps_t *deps, int64_t chart_id, const char *chart_rel,const char *project, const cbm_helm_dep_t *dep) {- const char *dir = dep->repository + K8S_SLEN("file://");- char *target_qn = NULL;- if (dir[0] && dir[0] != '/') { /* an absolute path names the build host, not this repo */- char rel[CBM_HELM_REPO_MAX + K8S_SLEN("./") + K8S_SLEN("/Chart.yaml")];- snprintf(rel, sizeof(rel), "%s%s/Chart.yaml", strncmp(dir, "../", 3) == 0 ? "" : "./", dir);- char *path = cbm_pipeline_resolve_relative_import(chart_rel, rel);- target_qn = path ? cbm_infra_qn(project, path, "helm-chart", NULL) : NULL;- free(path);- }if (deps->count == deps->cap) {int cap = deps->cap ? deps->cap * 2 : K8S_GROW_MIN;k8s_local_dep_t *grown =cbm_realloc(CBM_MEM_CLASS_OTHER, deps->items, (size_t)cap * sizeof(*grown));if (!grown) {- free(target_qn);return;}deps->items = grown;deps->cap = cap;}k8s_local_dep_t *d = &deps->items[deps->count++];- *d = (k8s_local_dep_t){.chart_id = chart_id, .target_qn = target_qn};+ *d = (k8s_local_dep_t){.chart_id = chart_id};+ d->target_qn = k8s_local_chart_qn(project, chart_rel, dep->repository + K8S_SLEN("file://"));snprintf(d->name, sizeof(d->name), "%s", dep->name);- d->chart_rel = strdup(chart_rel);+ d->chart_rel = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, chart_rel);d->props = k8s_dep_props(dep->repository);}static void k8s_local_deps_free(k8s_local_deps_t *deps) {for (int i = 0; i < deps->count; i++) {- free(deps->items[i].target_qn);- free(deps->items[i].chart_rel);+ cbm_free(CBM_MEM_CLASS_OTHER, deps->items[i].target_qn);+ cbm_free(CBM_MEM_CLASS_OTHER, deps->items[i].chart_rel);cbm_free(CBM_MEM_CLASS_OTHER, deps->items[i].props);}cbm_free(CBM_MEM_CLASS_OTHER, deps->items);diff --git a/src/pipeline/pass_pkgmap.c b/src/pipeline/pass_pkgmap.cindex a2014c5d3..f2a451f89 100644--- a/src/pipeline/pass_pkgmap.c+++ b/src/pipeline/pass_pkgmap.c@@ -31,7 +31,8 @@#include <string.h>#include <sys/stat.h>-/* Read an entire file into a malloc'd buffer. Returns NULL on failure. */+/* Read an entire file into a core-owned buffer (class extract; release with+ * cbm_free(CBM_MEM_CLASS_EXTRACT, ...)). Returns NULL on failure. */static char *pkgmap_read_file(const char *path, int *out_len) {FILE *f = cbm_fopen(path, "rb");if (!f) {@@ -44,7 +45,7 @@ static char *pkgmap_read_file(const char *path, int *out_len) {(void)fclose(f);return NULL;}- char *buf = (char *)malloc((size_t)size + SKIP_ONE);+ char *buf = (char *)cbm_alloc(CBM_MEM_CLASS_EXTRACT, (size_t)size + SKIP_ONE);if (!buf) {(void)fclose(f);return NULL;@@ -1201,7 +1202,7 @@ static int pkgmap_walk_dir(const char *abs_dir, const char *rel_dir, cbm_pkg_entif (cbm_pkgmap_try_parse(name, rel_path, source, source_len, entries)) {parsed++;}- free(source);+ cbm_free(CBM_MEM_CLASS_EXTRACT, source);}cbm_closedir(dir);return parsed;@@ -1247,7 +1248,7 @@ CBMHashTable *cbm_pkgmap_build_from_files(const cbm_file_info_t *files, int filecontinue;}cbm_pkgmap_try_parse(basename, files[i].rel_path, source, source_len, &entries);- free(source);+ cbm_free(CBM_MEM_CLASS_EXTRACT, source);}CBMHashTable *map = cbm_pkgmap_build(&entries, SKIP_ONE, project_name);@@ -1282,7 +1283,7 @@ CBMHashTable *cbm_pkgmap_build_from_repo(const char *repo_path, const cbm_file_icontinue;}cbm_pkgmap_try_parse(basename, files[i].rel_path, source, source_len, &entries);- free(source);+ cbm_free(CBM_MEM_CLASS_EXTRACT, source);}int from_walk = cbm_pkgmap_scan_repo(repo_path, &entries, excluded_dirs, excluded_count);