mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-04 18:58:00 +00:00
Compute K=64 MinHash signatures from normalized AST node-type trigrams
during function extraction, then generate SIMILAR_TO edges via LSH
(b=32, r=2) for function pairs with Jaccard >= 0.95.
- src/simhash/minhash.{h,c}: MinHash compute, Jaccard, hex encode/decode,
LSH index with band hashing for O(n) candidate generation
- src/pipeline/pass_similarity.c: post-pass reads fingerprints from node
properties, builds LSH index, emits SIMILAR_TO edges with jaccard and
same_file metadata. Same-language only, max 10 edges per node.
- internal/cbm/cbm.h: fingerprint fields on CBMDefinition
- internal/cbm/extract_defs.c: compute_fingerprint() hook at 3 extraction
sites after complexity, skip functions with < 10 AST body nodes
- pass_definitions.c + pass_parallel.c: serialize fingerprint to "fp" hex
in properties_json for both sequential and parallel pipeline paths
- pipeline.c + pipeline_incremental.c: register pass_similarity in both
full and incremental post-pass lists
- tests/test_simhash.c: 28 tests across 4 suites (core, LSH, edge gen,
pipeline integration with generated Go project + incremental)
159 lines
3.8 KiB
C
159 lines
3.8 KiB
C
/*
|
|
* test_main.c — Test runner entry point for pure C rewrite.
|
|
*
|
|
* Includes all test suites and runs them sequentially.
|
|
*/
|
|
/* Global test counters (declared extern in test_framework.h) */
|
|
int tf_pass_count = 0;
|
|
int tf_fail_count = 0;
|
|
int tf_skip_count = 0;
|
|
|
|
#include "test_framework.h"
|
|
#include <sqlite3.h>
|
|
|
|
/* Forward declarations of suite functions */
|
|
extern void suite_arena(void);
|
|
extern void suite_hash_table(void);
|
|
extern void suite_dyn_array(void);
|
|
extern void suite_str_intern(void);
|
|
extern void suite_log(void);
|
|
extern void suite_str_util(void);
|
|
extern void suite_platform(void);
|
|
extern void suite_extraction(void);
|
|
extern void suite_ac(void);
|
|
extern void suite_store_nodes(void);
|
|
extern void suite_store_edges(void);
|
|
extern void suite_store_search(void);
|
|
extern void suite_cypher(void);
|
|
extern void suite_mcp(void);
|
|
extern void suite_language(void);
|
|
extern void suite_userconfig(void);
|
|
extern void suite_gitignore(void);
|
|
extern void suite_discover(void);
|
|
extern void suite_graph_buffer(void);
|
|
extern void suite_registry(void);
|
|
extern void suite_pipeline(void);
|
|
extern void suite_fqn(void);
|
|
extern void suite_watcher(void);
|
|
extern void suite_lz4(void);
|
|
extern void suite_sqlite_writer(void);
|
|
extern void suite_go_lsp(void);
|
|
extern void suite_c_lsp(void);
|
|
extern void suite_store_arch(void);
|
|
extern void suite_store_bulk(void);
|
|
extern void suite_traces(void);
|
|
extern void suite_configlink(void);
|
|
extern void suite_infrascan(void);
|
|
extern void suite_cli(void);
|
|
extern void suite_system_info(void);
|
|
extern void suite_worker_pool(void);
|
|
extern void suite_parallel(void);
|
|
extern void suite_mem(void);
|
|
extern void suite_ui(void);
|
|
extern void suite_security(void);
|
|
extern void suite_yaml(void);
|
|
extern void suite_integration(void);
|
|
extern void suite_incremental(void);
|
|
extern void suite_simhash(void);
|
|
|
|
int main(void) {
|
|
printf("\n codebase-memory-mcp C test suite\n");
|
|
|
|
/* Foundation */
|
|
RUN_SUITE(arena);
|
|
RUN_SUITE(hash_table);
|
|
RUN_SUITE(dyn_array);
|
|
RUN_SUITE(str_intern);
|
|
RUN_SUITE(log);
|
|
RUN_SUITE(str_util);
|
|
RUN_SUITE(platform);
|
|
|
|
/* Existing C code regression tests */
|
|
RUN_SUITE(ac);
|
|
RUN_SUITE(extraction);
|
|
|
|
/* Store (M5) */
|
|
RUN_SUITE(store_nodes);
|
|
RUN_SUITE(store_edges);
|
|
RUN_SUITE(store_search);
|
|
RUN_SUITE(store_bulk);
|
|
|
|
/* Cypher (M6) */
|
|
RUN_SUITE(cypher);
|
|
|
|
/* MCP Server (M9) */
|
|
RUN_SUITE(mcp);
|
|
|
|
/* Discover (M2) */
|
|
RUN_SUITE(language);
|
|
RUN_SUITE(userconfig);
|
|
RUN_SUITE(gitignore);
|
|
RUN_SUITE(discover);
|
|
|
|
/* Graph Buffer (M7) */
|
|
RUN_SUITE(graph_buffer);
|
|
|
|
/* Pipeline (M8) */
|
|
RUN_SUITE(registry);
|
|
RUN_SUITE(pipeline);
|
|
RUN_SUITE(fqn);
|
|
|
|
/* Watcher (M10) */
|
|
RUN_SUITE(watcher);
|
|
|
|
/* LZ4 + SQLite writer */
|
|
RUN_SUITE(lz4);
|
|
RUN_SUITE(sqlite_writer);
|
|
|
|
/* LSP resolvers */
|
|
RUN_SUITE(go_lsp);
|
|
RUN_SUITE(c_lsp);
|
|
|
|
/* Architecture + ADR + Louvain */
|
|
RUN_SUITE(store_arch);
|
|
|
|
/* HTTP link */
|
|
|
|
/* Traces helpers */
|
|
RUN_SUITE(traces);
|
|
|
|
/* Config link */
|
|
RUN_SUITE(configlink);
|
|
|
|
/* Infrastructure scanning */
|
|
RUN_SUITE(infrascan);
|
|
|
|
/* CLI (install, update, config) */
|
|
RUN_SUITE(cli);
|
|
|
|
/* System info + worker pool (parallelism) */
|
|
RUN_SUITE(system_info);
|
|
RUN_SUITE(worker_pool);
|
|
|
|
/* Parallel pipeline */
|
|
RUN_SUITE(parallel);
|
|
|
|
/* mem + arena + slab integration */
|
|
RUN_SUITE(mem);
|
|
|
|
/* UI (config, embedded assets, layout) */
|
|
RUN_SUITE(ui);
|
|
|
|
/* Security defenses */
|
|
RUN_SUITE(security);
|
|
|
|
/* YAML parser */
|
|
RUN_SUITE(yaml);
|
|
|
|
/* SimHash / SIMILAR_TO */
|
|
RUN_SUITE(simhash);
|
|
|
|
/* Integration (end-to-end) */
|
|
RUN_SUITE(integration);
|
|
RUN_SUITE(incremental);
|
|
|
|
/* Release sqlite3 internal caches so ASan doesn't report them as leaks */
|
|
sqlite3_shutdown();
|
|
TEST_SUMMARY();
|
|
}
|