mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-11 09:25:35 +08:00
refactor(config): derive limits with shared stringify macro
Add CBM_STRINGIFY in src/foundation/constants.h:10-12 and replace the duplicate CBM_SCHEMA_STRINGIFY definitions in src/store/store.c:11848-12812. Use CBM_CONFIG_AUTO_DEP_LIMIT and CBM_STRINGIFY(CBM_DEFAULT_AUTO_DEP_LIMIT) in src/cli/cli.c:10542 so registry help and runtime dependency selection share one key and default. Add cli_config_registry_auto_dep_limit_uses_shared_default in tests/test_cli.c:6922. Verification: CLI 241 passed; store_arch 61 passed; schema_declared_property_keys 3 passed. Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
+1
-1
@@ -10539,7 +10539,7 @@ const cbm_config_entry_t CBM_CONFIG_REGISTRY[] = {
|
||||
"true|false",
|
||||
"Enable to trace calls into dependencies (e.g. find all callers of a library function). "
|
||||
"Disable for faster indexing when cross-package search is not needed."},
|
||||
{"auto_dep_limit", "20", NULL, "Dependencies",
|
||||
{CBM_CONFIG_AUTO_DEP_LIMIT, CBM_STRINGIFY(CBM_DEFAULT_AUTO_DEP_LIMIT), NULL, "Dependencies",
|
||||
"Max number of packages to auto-index",
|
||||
"0-10000",
|
||||
"When more packages are installed than this limit, the most-imported packages are selected "
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#ifndef CBM_CONSTANTS_H
|
||||
#define CBM_CONSTANTS_H
|
||||
|
||||
/* Expand a macro value before converting it to a string literal. */
|
||||
#define CBM_STRINGIFY_INNER(value) #value
|
||||
#define CBM_STRINGIFY(value) CBM_STRINGIFY_INNER(value)
|
||||
|
||||
/* ── Allocation counts ───────────────────────────────────────── */
|
||||
enum { CBM_ALLOC_ONE = 1 }; /* calloc(CBM_ALLOC_ONE, sizeof(T)) */
|
||||
|
||||
|
||||
+4
-7
@@ -11845,9 +11845,6 @@ int cbm_deduplicate_hops(const cbm_node_hop_t *hops, int hop_count, cbm_node_hop
|
||||
|
||||
/* ── Schema ─────────────────────────────────────────────────────── */
|
||||
|
||||
#define CBM_SCHEMA_STRINGIFY_INNER(value) #value
|
||||
#define CBM_SCHEMA_STRINGIFY(value) CBM_SCHEMA_STRINGIFY_INNER(value)
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
const char *text;
|
||||
@@ -12544,7 +12541,7 @@ static int get_schema_impl(cbm_store_t *s, const char *project, cbm_schema_info_
|
||||
"WHERE nodes.project = ?1 AND nodes.label = ?2 "
|
||||
" AND nodes.properties != '{}' "
|
||||
"ORDER BY je.key "
|
||||
"LIMIT " CBM_SCHEMA_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";";
|
||||
"LIMIT " CBM_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";";
|
||||
|
||||
for (int i = 0; i < out->node_label_count; i++) {
|
||||
const schema_text_bind_t binds[] = {{ST_COL_1, project},
|
||||
@@ -12622,7 +12619,7 @@ static int get_schema_impl(cbm_store_t *s, const char *project, cbm_schema_info_
|
||||
"WHERE edges.project = ?1 AND edges.type = ?2 "
|
||||
" AND edges.properties != '{}' "
|
||||
"ORDER BY je.key "
|
||||
"LIMIT " CBM_SCHEMA_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";";
|
||||
"LIMIT " CBM_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";";
|
||||
|
||||
for (int i = 0; i < out->edge_type_count; i++) {
|
||||
const schema_text_bind_t binds[] = {{ST_COL_1, project},
|
||||
@@ -12701,7 +12698,7 @@ static int get_schema_overlay_impl(cbm_store_t *s, const char *project, cbm_sche
|
||||
"WHERE n.project = ?3 AND n.label = ?4 "
|
||||
" AND n.properties != '{}' "
|
||||
"ORDER BY je.key LIMIT "
|
||||
CBM_SCHEMA_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";",
|
||||
CBM_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";",
|
||||
active_cte);
|
||||
if (nsql <= 0 || (size_t)nsql >= sizeof(sql)) {
|
||||
cbm_store_schema_free(out);
|
||||
@@ -12809,7 +12806,7 @@ static int get_schema_overlay_impl(cbm_store_t *s, const char *project, cbm_sche
|
||||
"WHERE src.project = ?3 AND dst.project = ?3 AND e.type = ?4 "
|
||||
" AND e.properties != '{}' "
|
||||
"ORDER BY je.key LIMIT "
|
||||
CBM_SCHEMA_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";",
|
||||
CBM_STRINGIFY(CBM_STORE_SCHEMA_PROPERTY_KEY_LIMIT) ";",
|
||||
active_cte);
|
||||
if (nsql <= 0 || (size_t)nsql >= sizeof(sql)) {
|
||||
cbm_store_schema_free(out);
|
||||
|
||||
@@ -6918,6 +6918,20 @@ TEST(cli_config_registry_includes_query_max_rows) {
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST(cli_config_registry_auto_dep_limit_uses_shared_default) {
|
||||
const cbm_config_entry_t *found = NULL;
|
||||
for (int i = 0; CBM_CONFIG_REGISTRY[i].key; i++) {
|
||||
if (strcmp(CBM_CONFIG_REGISTRY[i].key, CBM_CONFIG_AUTO_DEP_LIMIT) == 0) {
|
||||
found = &CBM_CONFIG_REGISTRY[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_NOT_NULL(found);
|
||||
ASSERT_EQ(atoi(found->default_val), CBM_DEFAULT_AUTO_DEP_LIMIT);
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST(cli_config_registry_reindex_startup_guidance_is_precise) {
|
||||
const cbm_config_entry_t *found = NULL;
|
||||
for (int i = 0; CBM_CONFIG_REGISTRY[i].key; i++) {
|
||||
@@ -7740,6 +7754,7 @@ SUITE(cli) {
|
||||
RUN_TEST(cli_config_get_effective_env_overrides_db);
|
||||
RUN_TEST(cli_config_registry_includes_dep_ranking_toggle);
|
||||
RUN_TEST(cli_config_registry_includes_query_max_rows);
|
||||
RUN_TEST(cli_config_registry_auto_dep_limit_uses_shared_default);
|
||||
RUN_TEST(cli_config_registry_reindex_startup_guidance_is_precise);
|
||||
RUN_TEST(cli_configuration_doc_auto_index_default_matches_registry);
|
||||
RUN_TEST(cli_config_delete);
|
||||
|
||||
Reference in New Issue
Block a user