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 origin/main into worktree-php-lsp-integration

Martin Vogele6f4aa74bda9
diff --cc Makefile.cbm
index 3f380fb9a,36c0617ba..6b26f6ca9
--- a/Makefile.cbm
+++ b/Makefile.cbm
@@@ -309,8 -310,18 +310,20 @@@ TEST_GO_LSP_SRCS = tests/test_go_lsp.
TEST_C_LSP_SRCS = tests/test_c_lsp.c
+TEST_PHP_LSP_SRCS = tests/test_php_lsp.c
+
+ TEST_SCOPE_SRCS = tests/test_scope.c
+
+ TEST_TYPE_REP_SRCS = tests/test_type_rep.c
+
+ TEST_PY_LSP_SRCS = tests/test_py_lsp.c
+
+ TEST_PY_LSP_BENCH_SRCS = tests/test_py_lsp_bench.c
+
+ TEST_PY_LSP_STRESS_SRCS = tests/test_py_lsp_stress.c
+
+ TEST_PY_LSP_SCALE_SRCS = tests/test_py_lsp_scale.c
+
TEST_INTEGRATION_SRCS = tests/test_integration.c tests/test_incremental.c
TEST_TRACES_SRCS = tests/test_traces.c
@@@ -328,7 -339,9 +341,9 @@@ TEST_YAML_SRCS = tests/test_yaml.
TEST_SIMHASH_SRCS = tests/test_simhash.c
- ALL_TEST_SRCS = $(TEST_FOUNDATION_SRCS) $(TEST_EXTRACTION_SRCS) $(TEST_STORE_SRCS) $(TEST_CYPHER_SRCS) $(TEST_MCP_SRCS) $(TEST_DISCOVER_SRCS) $(TEST_GRAPH_BUFFER_SRCS) $(TEST_PIPELINE_SRCS) $(TEST_WATCHER_SRCS) $(TEST_LZ4_SRCS) $(TEST_ZSTD_SRCS) $(TEST_ARTIFACT_SRCS) $(TEST_SQLITE_WRITER_SRCS) $(TEST_GO_LSP_SRCS) $(TEST_C_LSP_SRCS) $(TEST_PHP_LSP_SRCS) $(TEST_TRACES_SRCS) $(TEST_CLI_SRCS) $(TEST_MEM_SRCS) $(TEST_UI_SRCS) $(TEST_SECURITY_SRCS) $(TEST_YAML_SRCS) $(TEST_SIMHASH_SRCS) $(TEST_INTEGRATION_SRCS)
+ TEST_STACK_OVERFLOW_SRCS = tests/test_stack_overflow.c
+
-ALL_TEST_SRCS = $(TEST_FOUNDATION_SRCS) $(TEST_EXTRACTION_SRCS) $(TEST_STORE_SRCS) $(TEST_CYPHER_SRCS) $(TEST_MCP_SRCS) $(TEST_DISCOVER_SRCS) $(TEST_GRAPH_BUFFER_SRCS) $(TEST_PIPELINE_SRCS) $(TEST_WATCHER_SRCS) $(TEST_LZ4_SRCS) $(TEST_ZSTD_SRCS) $(TEST_ARTIFACT_SRCS) $(TEST_SQLITE_WRITER_SRCS) $(TEST_GO_LSP_SRCS) $(TEST_C_LSP_SRCS) $(TEST_SCOPE_SRCS) $(TEST_TYPE_REP_SRCS) $(TEST_PY_LSP_SRCS) $(TEST_PY_LSP_BENCH_SRCS) $(TEST_PY_LSP_STRESS_SRCS) $(TEST_PY_LSP_SCALE_SRCS) $(TEST_TRACES_SRCS) $(TEST_CLI_SRCS) $(TEST_MEM_SRCS) $(TEST_UI_SRCS) $(TEST_SECURITY_SRCS) $(TEST_YAML_SRCS) $(TEST_SIMHASH_SRCS) $(TEST_STACK_OVERFLOW_SRCS) $(TEST_INTEGRATION_SRCS)
++ALL_TEST_SRCS = $(TEST_FOUNDATION_SRCS) $(TEST_EXTRACTION_SRCS) $(TEST_STORE_SRCS) $(TEST_CYPHER_SRCS) $(TEST_MCP_SRCS) $(TEST_DISCOVER_SRCS) $(TEST_GRAPH_BUFFER_SRCS) $(TEST_PIPELINE_SRCS) $(TEST_WATCHER_SRCS) $(TEST_LZ4_SRCS) $(TEST_ZSTD_SRCS) $(TEST_ARTIFACT_SRCS) $(TEST_SQLITE_WRITER_SRCS) $(TEST_GO_LSP_SRCS) $(TEST_C_LSP_SRCS) $(TEST_PHP_LSP_SRCS) $(TEST_SCOPE_SRCS) $(TEST_TYPE_REP_SRCS) $(TEST_PY_LSP_SRCS) $(TEST_PY_LSP_BENCH_SRCS) $(TEST_PY_LSP_STRESS_SRCS) $(TEST_PY_LSP_SCALE_SRCS) $(TEST_TRACES_SRCS) $(TEST_CLI_SRCS) $(TEST_MEM_SRCS) $(TEST_UI_SRCS) $(TEST_SECURITY_SRCS) $(TEST_YAML_SRCS) $(TEST_SIMHASH_SRCS) $(TEST_STACK_OVERFLOW_SRCS) $(TEST_INTEGRATION_SRCS)
# ── Build directories ────────────────────────────────────────────
diff --cc internal/cbm/cbm.c
index 2f8cb7436,5d7a8b8b8..1049319b7
--- a/internal/cbm/cbm.c
+++ b/internal/cbm/cbm.c
@@@ -5,7 -5,7 +5,8 @@@
#include "extract_unified.h"
#include "lsp/go_lsp.h"
#include "lsp/c_lsp.h"
+#include "lsp/php_lsp.h"
+ #include "lsp/py_lsp.h"
#include "preprocessor.h"
#include "foundation/compat.h"
#include "tree_sitter/api.h" // TSParser, TSNode, TSTree, TSInput, TSLanguage, TSPoint, TSParseOptions, TSParseState
@@@ -358,9 -358,9 +359,12 @@@ CBMFileResult *cbm_extract_file(const c
if (language == CBM_LANG_C || language == CBM_LANG_CPP || language == CBM_LANG_CUDA) {
cbm_run_c_lsp(a, result, source, source_len, root, language != CBM_LANG_C);
}
+ if (language == CBM_LANG_PHP) {
+ cbm_run_php_lsp(a, result, source, source_len, root);
+ }
+ if (language == CBM_LANG_PYTHON) {
+ cbm_run_py_lsp(a, result, source, source_len, root);
+ }
atomic_fetch_add(&total_lsp_ns, now_ns() - lsp_start);
// Second pass: preprocess C/C++/CUDA and extract additional macro-hidden calls.
diff --cc internal/cbm/lsp_all.c
index 7c84304cd,f4192f851..7369b11dd
--- a/internal/cbm/lsp_all.c
+++ b/internal/cbm/lsp_all.c
@@@ -10,5 -10,5 +10,7 @@@
#include "lsp/c_lsp.c"
#include "lsp/generated/c_stdlib_data.c"
#include "lsp/generated/cpp_stdlib_data.c"
+#include "lsp/php_lsp.c"
+#include "lsp/generated/php_stdlib_data.c"
+ #include "lsp/generated/python_stdlib_data.c"
+ #include "lsp/py_lsp.c"
diff --cc src/pipeline/pass_calls.c
index cf5dd97b8,0f318dc8b..8d564aba2
--- a/src/pipeline/pass_calls.c
+++ b/src/pipeline/pass_calls.c
@@@ -322,55 -322,40 +322,42 @@@ static const cbm_gbuf_node_t *calls_fin
return src;
}
- /* Return the substring after the last '.' (short name) of a qualified name. */
- static const char *qn_short_name(const char *qn) {
- if (!qn) return NULL;
- const char *last = qn;
- for (const char *p = qn; *p; p++) {
- if (*p == '.') last = p + 1;
- }
- return last;
- }
-
- /* Look up an LSP-resolved override for this call site.
- *
- * Match rule: the LSP emits CBMResolvedCall entries whose caller_qn matches
- * the call's enclosing function and whose callee_qn ends in "." + short
- * name. When the unified extractor's `callee_name` short-matches an LSP
- * entry, prefer the LSP attribution.
- *
- * Returns a cbm_resolution_t with non-empty qualified_name on hit, empty
- * struct on miss. The strategy is taken verbatim from the LSP entry. */
- static cbm_resolution_t lsp_override_resolution(const CBMFileResult *result, const CBMCall *call) {
- cbm_resolution_t empty = {0};
- if (!result || !call || !call->callee_name || !call->enclosing_func_qn) {
- return empty;
- }
- if (result->resolved_calls.count == 0) {
- return empty;
- }
- /* The unified extractor's callee_name for PHP method/static/function calls
- * is the bare method name. The LSP's callee_qn ends in "." + that name. */
- const char *short_name = call->callee_name;
- /* In case some extractor variants produce "Class.method", take the trailing
- * segment for matching. */
- const char *short_only = qn_short_name(short_name);
- if (!short_only || !short_only[0]) {
- return empty;
- }
- size_t snlen = strlen(short_only);
-
+ /* Confidence floor below which LSP-resolved calls are ignored and the
+ * registry resolver is consulted instead. Locked at 0.6 per the v1
- * Python-LSP integration plan; revisit when telemetry justifies a knob. */
++ * Python-LSP integration plan; revisit when telemetry justifies a knob.
++ * Applies to every language whose LSP populates result->resolved_calls
++ * (Go, C, Python, PHP). */
+ #define CBM_LSP_CONFIDENCE_FLOOR 0.6f
+
+ /* Look up the highest-confidence LSP-resolved call entry whose caller QN
+ * matches the textual call's enclosing function and whose callee QN
+ * short-name matches the textual callee. Returns a pointer into
+ * result->resolved_calls or NULL if no qualifying entry exists. */
+ static const CBMResolvedCall *find_lsp_resolution(const CBMResolvedCallArray *arr,
+ const CBMCall *call) {
+ if (!arr || arr->count == 0 || !call) {
+ return NULL;
+ }
+ if (!call->enclosing_func_qn || !call->callee_name) {
+ return NULL;
+ }
const CBMResolvedCall *best = NULL;
- for (int i = 0; i < result->resolved_calls.count; i++) {
- const CBMResolvedCall *rc = &result->resolved_calls.items[i];
- if (!rc->caller_qn || !rc->callee_qn) continue;
- if (strcmp(rc->caller_qn, call->enclosing_func_qn) != 0) continue;
- /* require callee_qn to end in "." + short_only */
- size_t qlen = strlen(rc->callee_qn);
- if (qlen <= snlen) continue;
- if (rc->callee_qn[qlen - snlen - 1] != '.') continue;
- if (strcmp(rc->callee_qn + qlen - snlen, short_only) != 0) continue;
- if (rc->confidence < 0.5f) continue;
+ for (int i = 0; i < arr->count; i++) {
+ const CBMResolvedCall *rc = &arr->items[i];
+ if (!rc->caller_qn || !rc->callee_qn) {
+ continue;
+ }
+ if (rc->confidence < CBM_LSP_CONFIDENCE_FLOOR) {
+ continue;
+ }
+ if (strcmp(rc->caller_qn, call->enclosing_func_qn) != 0) {
+ continue;
+ }
+ const char *short_name = strrchr(rc->callee_qn, '.');
+ short_name = short_name ? short_name + SKIP_ONE : rc->callee_qn;
+ if (strcmp(short_name, call->callee_name) != 0) {
+ continue;
+ }
if (!best || rc->confidence > best->confidence) {
best = rc;
}
diff --cc tests/test_main.c
index 09e642915,9868e01a2..36675186a
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@@ -41,7 -42,12 +42,13 @@@ extern void suite_artifact(void)
extern void suite_sqlite_writer(void);
extern void suite_go_lsp(void);
extern void suite_c_lsp(void);
+extern void suite_php_lsp(void);
+ extern void suite_scope(void);
+ extern void suite_type_rep(void);
+ extern void suite_py_lsp(void);
+ extern void suite_py_lsp_bench(void);
+ extern void suite_py_lsp_stress(void);
+ extern void suite_py_lsp_scale(void);
extern void suite_store_arch(void);
extern void suite_store_bulk(void);
extern void suite_traces(void);
@@@ -113,9 -121,14 +122,15 @@@ int main(void)
RUN_SUITE(artifact);
/* LSP resolvers */
+ RUN_SUITE(scope);
+ RUN_SUITE(type_rep);
RUN_SUITE(go_lsp);
RUN_SUITE(c_lsp);
+ RUN_SUITE(php_lsp);
+ RUN_SUITE(py_lsp);
+ RUN_SUITE(py_lsp_bench);
+ RUN_SUITE(py_lsp_stress);
+ RUN_SUITE(py_lsp_scale);
/* Architecture + ADR + Louvain */
RUN_SUITE(store_arch);