Skip to content

Commit 5e04ce2

Browse files
committed
Merge step-2 baseline and refresh memory-core gate for the CLI fork
Merge origin/sync/upstream-step2, including baseline commit 4401d46. Resolve the baseline-only conflict by regenerating with: python3 scripts/lint-memory-core.py --write-baseline The CLI operation, activation, configuration and daemon code predates the upstream memory-core gate and was absent from its MCP baseline. Record the fork's existing raw-allocator sites, remove deleted MCP files, and tighten counts for upstream memory-core migrations. This records inherited debt; it does not claim that raw allocations were migrated or permit future growth. Complete the final operation-layer source checks: root-owner ambiguity names all competing projects using upstream's memory-core list builder, and source search uses upstream's nullable comparison helper for stable tie ordering. The existing native daemon root-owner regression asserts both names. No Co-Authored-By trailer. No full test suites run, as requested.
2 parents 8dca7d1 + 4401d46 commit 5e04ce2

3 files changed

Lines changed: 77 additions & 17 deletions

File tree

‎scripts/memory-core-baseline.txt‎

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal/cbm/ac.c 20
77
internal/cbm/arena.c 3
88
internal/cbm/cbm.c 13
99
internal/cbm/extract_defs.c 4
10-
internal/cbm/helpers.c 3
10+
internal/cbm/helpers.c 4
1111
internal/cbm/lsp/c_lsp.c 4
1212
internal/cbm/lsp/perl_lsp.c 21
1313
internal/cbm/lsp/py_lsp.c 2
@@ -16,21 +16,20 @@ internal/cbm/service_patterns.c 2
1616
internal/cbm/sqlite_writer.c 74
1717
src/cli/activation_transaction.c 80
1818
src/cli/agent_clients.c 73
19-
src/cli/agent_profiles.c 7
20-
src/cli/cli.c 170
21-
src/cli/client_adapter.c 3
19+
src/cli/cli.c 133
2220
src/cli/config_edit_path.c 2
2321
src/cli/config_json_like.c 142
2422
src/cli/config_text_edit.c 72
25-
src/cli/config_toml_edit.c 85
23+
src/cli/config_toml_edit.c 73
2624
src/cli/config_yaml_edit.c 117
27-
src/cli/hook_augment.c 31
25+
src/cli/hook_augment.c 27
26+
src/cli/legacy_agent_profiles.c 7
2827
src/cypher/cypher.c 132
29-
src/daemon/application.c 107
28+
src/daemon/application.c 113
3029
src/daemon/bootstrap.c 13
3130
src/daemon/daemon.c 31
32-
src/daemon/frontend.c 12
3331
src/daemon/ipc.c 146
32+
src/daemon/maintenance_monitor.c 3
3433
src/daemon/project_lock.c 6
3534
src/daemon/runtime.c 45
3635
src/daemon/service.c 6
@@ -39,20 +38,44 @@ src/discover/discover.c 31
3938
src/discover/gitignore.c 12
4039
src/discover/userconfig.c 15
4140
src/foundation/diagnostics.c 7
41+
src/foundation/json_args.c 1
4242
src/foundation/lock_registry.c 18
4343
src/foundation/platform.c 11
4444
src/foundation/platform.h 5
4545
src/foundation/private_file_lock.c 56
4646
src/foundation/str_intern.c 7
4747
src/foundation/subprocess.c 24
4848
src/foundation/win_utf8.h 17
49-
src/foundation/workspace.c 3
49+
src/foundation/workspace.c 5
5050
src/foundation/yaml.c 10
5151
src/git/git_context.c 18
52-
src/main.c 32
53-
src/mcp/compact_out.c 39
54-
src/mcp/index_supervisor.c 8
55-
src/mcp/mcp.c 784
52+
src/main.c 35
53+
src/operations/adr.c 50
54+
src/operations/architecture.c 88
55+
src/operations/changes.c 54
56+
src/operations/command_runner.c 1
57+
src/operations/compact_out.c 39
58+
src/operations/compare.c 18
59+
src/operations/coverage.c 7
60+
src/operations/cross_repo.c 24
61+
src/operations/execute.c 2
62+
src/operations/file_outline.c 15
63+
src/operations/index.c 78
64+
src/operations/index_supervisor.c 8
65+
src/operations/json_args.c 1
66+
src/operations/mutation.c 5
67+
src/operations/project_arg.c 5
68+
src/operations/query.c 35
69+
src/operations/read.c 13
70+
src/operations/reliability_events.c 4
71+
src/operations/result_wire.c 1
72+
src/operations/schema.c 10
73+
src/operations/search.c 13
74+
src/operations/session_state.c 12
75+
src/operations/snippet.c 24
76+
src/operations/source_search.c 87
77+
src/operations/store_host.c 11
78+
src/operations/trace.c 10
5679
src/pipeline/artifact.c 38
5780
src/pipeline/fqn.c 23
5881
src/pipeline/lsp_resolve.h 4
@@ -84,7 +107,7 @@ src/pipeline/registry.c 17
84107
src/pipeline/worker_pool.c 2
85108
src/store/store.c 358
86109
src/ui/config.c 12
87-
src/ui/http_server.c 31
110+
src/ui/http_server.c 30
88111
src/ui/httpd.c 21
89112
src/ui/layout3d.c 66
90113
src/watcher/watcher.c 33

‎src/operations/index.c‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,9 +1017,25 @@ static bool index_validate_metrics_out(const char *json, const cbm_operation_run
10171017
}
10181018

10191019
/* Unnamed starts and polls must use the same existing owner (#2134). */
1020+
static bool index_root_owner_append(char **list, size_t *len, size_t *cap, const char *name) {
1021+
size_t need = *len + strlen(name) + 3U;
1022+
if (need > *cap) {
1023+
size_t grown_cap = need * 2U;
1024+
char *grown = cbm_realloc(CBM_MEM_CLASS_OTHER, *list, grown_cap);
1025+
if (!grown)
1026+
return false;
1027+
*list = grown;
1028+
*cap = grown_cap;
1029+
}
1030+
*len += (size_t)snprintf(*list + *len, *cap - *len, "%s%s", *len ? ", " : "", name);
1031+
return true;
1032+
}
1033+
10201034
static char *index_root_project(const char *path, char *error, size_t error_size) {
10211035
char *derived = cbm_project_name_from_path(path);
10221036
char *owner = NULL;
1037+
char *owners = NULL;
1038+
size_t owners_len = 0, owners_cap = 0;
10231039
bool ambiguous = false;
10241040
for (int offset = 0; derived;) {
10251041
char args[CBM_SZ_256];
@@ -1037,6 +1053,7 @@ static char *index_root_project(const char *path, char *error, size_t error_size
10371053
cbm_operation_result_dispose(&listing);
10381054
free(owner);
10391055
free(derived);
1056+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10401057
return NULL;
10411058
}
10421059
size_t i, max;
@@ -1050,17 +1067,28 @@ static char *index_root_project(const char *path, char *error, size_t error_size
10501067
yyjson_doc_free(doc);
10511068
cbm_operation_result_dispose(&listing);
10521069
free(owner);
1070+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10531071
return derived;
10541072
}
10551073
if (owner && strcmp(owner, name))
10561074
ambiguous = true;
1075+
if (!index_root_owner_append(&owners, &owners_len, &owners_cap, name)) {
1076+
snprintf(error, error_size, "out of memory while resolving index root owner");
1077+
yyjson_doc_free(doc);
1078+
cbm_operation_result_dispose(&listing);
1079+
free(owner);
1080+
free(derived);
1081+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
1082+
return NULL;
1083+
}
10571084
if (!owner) {
10581085
owner = index_strdup(name);
10591086
if (!owner) {
10601087
snprintf(error, error_size, "out of memory while resolving index root owner");
10611088
yyjson_doc_free(doc);
10621089
cbm_operation_result_dispose(&listing);
10631090
free(derived);
1091+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10641092
return NULL;
10651093
}
10661094
}
@@ -1075,21 +1103,26 @@ static char *index_root_project(const char *path, char *error, size_t error_size
10751103
snprintf(error, error_size, "invalid project listing continuation");
10761104
free(owner);
10771105
free(derived);
1106+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10781107
return NULL;
10791108
}
10801109
offset = next;
10811110
}
10821111
if (ambiguous) {
10831112
snprintf(error, error_size,
1084-
"several indexed projects share root_path %s; pass --name to choose", path);
1113+
"several indexed projects share root_path %s: %s. Pass --name to choose", path,
1114+
owners);
10851115
free(owner);
10861116
free(derived);
1117+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10871118
return NULL;
10881119
}
10891120
if (owner) {
10901121
free(derived);
1122+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10911123
return owner;
10921124
}
1125+
cbm_free(CBM_MEM_CLASS_OTHER, owners);
10931126
return derived;
10941127
}
10951128

‎src/operations/source_search.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ static int compute_search_score(const search_result_t *r) {
253253
return score;
254254
}
255255

256+
static int nullable_strcmp(const char *a, const char *b) {
257+
return strcmp(a ? a : "", b ? b : "");
258+
}
259+
256260
static int search_result_cmp(const void *a, const void *b) {
257261
const search_result_t *ra = (const search_result_t *)a;
258262
const search_result_t *rb = (const search_result_t *)b;
@@ -262,11 +266,11 @@ static int search_result_cmp(const void *a, const void *b) {
262266
}
263267
/* Equal scores are common; order them by identity so result_offset pages
264268
* are stable across calls. */
265-
int qn_order = strcmp(ra->qualified_name, rb->qualified_name);
269+
int qn_order = nullable_strcmp(ra->qualified_name, rb->qualified_name);
266270
if (qn_order != 0) {
267271
return qn_order;
268272
}
269-
int file_order = strcmp(ra->file, rb->file);
273+
int file_order = nullable_strcmp(ra->file, rb->file);
270274
if (file_order != 0) {
271275
return file_order;
272276
}

0 commit comments

Comments
 (0)