Skip to content

Commit 97628c0

Browse files
committed
Merge origin/main into fix/swift-init-extraction
Signed-off-by: Martin Vogel <[email protected]>
2 parents 5efa564 + 006101a commit 97628c0

59 files changed

Lines changed: 7645 additions & 4339 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile.cbm‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ endif
4545

4646
# -Wdate-time: with -Werror, any use of __DATE__/__TIME__/__TIMESTAMP__ fails the
4747
# build. Build-time entropy is how one identical source tree produced a new hash
48-
# on every compile (see the local patch in vendored/mimalloc/src/options.c) —
49-
# once removed, it must not creep back through a new call site.
48+
# on every compile (mimalloc's version banner, patched locally until upstream
49+
# dropped the clock in v3.4.5; see vendored/mimalloc/PATCHES.md) — once
50+
# removed, it must not creep back through a new call site.
5051
CFLAGS_COMMON = -std=c11 -D_DEFAULT_SOURCE -D_GNU_SOURCE -Wall -Wextra -Werror \
5152
-Wno-unused-parameter -Wno-sign-compare -Wdate-time \
5253
$(GCC_ONLY_FLAGS) \
@@ -182,8 +183,9 @@ endif
182183
ifeq ($(IS_MINGW),yes)
183184
# --no-insert-timestamp: the PE header otherwise carries the link wall clock, so
184185
# two Windows builds of identical source are never byte-identical and every
185-
# release is a brand-new file to a reputation system. Same motivation as the
186-
# mimalloc __DATE__ patch; ELF and Mach-O have no equivalent field to clear.
186+
# release is a brand-new file to a reputation system. Same motivation as
187+
# dropping mimalloc's __DATE__ banner; ELF and Mach-O have no equivalent field
188+
# to clear.
187189
WIN32_LIBS := -lws2_32 -lpsapi -lshell32 -ladvapi32 -lbcrypt -Wl,--allow-multiple-definition -Wl,--stack,8388608 -Wl,--no-insert-timestamp -static
188190
endif
189191

@@ -644,6 +646,18 @@ ifneq ($(filter yes,$(IS_MINGW) $(IS_LINUX)),)
644646
MIMALLOC_OVERRIDE_DEFINE := -DMI_MALLOC_OVERRIDE=1
645647
GLOBAL_OVERRIDE_DEFINE := -DCBM_MEM_GLOBAL_OVERRIDE=1
646648
endif
649+
# MI_MINGW_UCRT64: since 3.5.3, mimalloc treats a MinGW build as having a
650+
# process-attach hook only when this is defined (src/prim/windows/prim.c);
651+
# upstream's CMake sets it, this Makefile must too. Without it src/prim/prim.c
652+
# also compiles its constructor, so _mi_auto_process_init runs twice (that
653+
# constructor plus the CRT TLS callback) and the second options flush writes a
654+
# stray newline to stderr before main: a blank first line on every run, which
655+
# failed smoke-win's one-line --version check. Every MinGW toolchain we build
656+
# with (MSYS2 CLANG64/CLANGARM64) is UCRT. 3.3.2 had no such condition.
657+
MIMALLOC_WIN_DEFINE :=
658+
ifeq ($(IS_MINGW),yes)
659+
MIMALLOC_WIN_DEFINE := -DMI_MINGW_UCRT64=1
660+
endif
647661
# MI_DEBUG=0: the production allocator is mimalloc's RELEASE build. Its header
648662
# defaults to MI_DEBUG=2 unless NDEBUG is defined, and nothing here defined it,
649663
# so every shipped binary up to v0.11.0 ran mimalloc's debug build: internal
@@ -653,15 +667,19 @@ endif
653667
# work inside the allocator (2026-09-17). Committed-bytes accounting, which the
654668
# memory budget reads, is kept in every build (subproc stats, not MI_STAT).
655669
# The TEST build below keeps mimalloc's debug checks.
670+
# MI_PROFILE=0: mimalloc 3.5.2+ compiles its allocation-sampling profiler in by
671+
# default, which puts a sample countdown on the allocation path. The product
672+
# never uses it, so the production allocator leaves it out (the contract in
673+
# tests/test_prod_allocator_contract.sh checks the banner has no profiling line).
656674
MIMALLOC_CFLAGS = -std=c11 -O2 -w \
657675
-Ivendored/mimalloc/include \
658676
-Ivendored/mimalloc/src \
659-
-DMI_OVERRIDE=1 -DMI_DEBUG=0 \
660-
$(MIMALLOC_OVERRIDE_DEFINE)
677+
-DMI_OVERRIDE=1 -DMI_DEBUG=0 -DMI_PROFILE=0 \
678+
$(MIMALLOC_OVERRIDE_DEFINE) $(MIMALLOC_WIN_DEFINE)
661679
MIMALLOC_CFLAGS_TEST = -std=c11 -g -O1 -w \
662680
-Ivendored/mimalloc/include \
663681
-Ivendored/mimalloc/src \
664-
-DMI_OVERRIDE=0
682+
-DMI_OVERRIDE=0 $(MIMALLOC_WIN_DEFINE)
665683

666684
# sqlite3 (vendored amalgamation — compiled ourselves for ASan instrumentation)
667685
# SQLITE_ENABLE_FTS5: enables the FTS5 full-text search extension used by the

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ SQLite databases stored at `~/.cache/codebase-memory-mcp/`. Persists across rest
10371037

10381038
## Troubleshooting
10391039

1040+
Windows users: see [Windows troubleshooting](docs/WINDOWS_TROUBLESHOOTING.md) for versioned known issues and workarounds.
1041+
10401042
| Problem | Fix |
10411043
|---------|-----|
10421044
| `/mcp` doesn't show the server | Check `.mcp.json` path is absolute. Restart agent. Test: `echo '{}' \| /path/to/binary` should output JSON. |

‎THIRD_PARTY.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ License summary:
121121
| wyhash | `internal/cbm/vendored/wyhash/` | Unlicense (public domain) | [wangyi-fudan/wyhash](https://github.com/wangyi-fudan/wyhash) |
122122

123123
Local modifications to these libraries are documented next to the
124-
vendored sources (currently only SQLite: `vendored/sqlite3/PATCHES.md`,
125-
raising the Unix VFS `MAX_PATHNAME` ceiling from 512 to 4096 to match
126-
CBM's 4 KiB path support). Patches must be reapplied on every upstream
127-
refresh and are covered by `scripts/vendored-checksums.txt`.
124+
vendored sources: `vendored/sqlite3/PATCHES.md` (raising the Unix VFS
125+
`MAX_PATHNAME` ceiling from 512 to 4096 to match CBM's 4 KiB path support)
126+
and `vendored/mimalloc/PATCHES.md` (the upstream source pin, mimalloc v3.5.3
127+
at commit `d4881d33`, plus the macOS decommit-recommit change and one comment
128+
rewording). Patches must be reapplied on every upstream refresh and are
129+
covered by `scripts/vendored-checksums.txt`.
128130

129131
The graph-UI HTTP server is a first-party implementation
130132
(`src/ui/httpd.c` + `src/ui/http_server.c`) — no third-party HTTP library

‎docs/WINDOWS_TROUBLESHOOTING.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Windows Troubleshooting
2+
3+
This page collects known Windows-specific symptoms, with the version range each affects, confirmed workarounds, and links to the canonical tracking issues.
4+
5+
## Non-ASCII paths in CBM_CACHE_DIR or CBM_ALLOWED_ROOT
6+
7+
**Symptom:** Configuration appears not to persist, the config database cannot be opened (`error: cannot open config database`), or repositories inside `CBM_ALLOWED_ROOT` are rejected during indexing.
8+
9+
**Affected versions:** Affects v0.9.x and earlier. Fixed in v0.10.0 (environment variables are read as wide strings via `GetEnvironmentVariableW`).
10+
11+
**Workaround:** On an older build, use ASCII-only paths for these two variables or upgrade with `install.ps1`.
12+
13+
**Tracking:** #1165.
14+
15+
## Upgrade completes but binary version does not change
16+
17+
**Symptom:** `codebase-memory-mcp update` reports success and downloads files, but `codebase-memory-mcp --version` still reports the previous version (with `.exe.old` remaining alongside).
18+
19+
**Affected versions:** Affects v0.9.x and earlier (in-process self-update on Windows). From v0.10.0, `update` prints the `install.ps1` command instead of replacing itself.
20+
21+
**Workaround:** On an older build, run `install.ps1` once; it replaces the binary out-of-process and verifies the installed version.
22+
23+
**Tracking:** #1168 (closed; fixed in v0.10.0).
24+
25+
## Index worker hangs, crashes, or leaves an empty worker log
26+
27+
**Symptom:** `index_repository` reports worker hangs or crashes. (An *empty* worker log is a separate, fixed bug: v0.10.4 and earlier.)
28+
29+
**Affected versions:** Empty worker logs affect v0.10.4 and earlier (fixed in v0.10.5). Misleading "crashed on a file" reports for returned errors fixed in v0.10.0. From v0.11.0, the Windows worker is memory-capped. From v0.12.0, a worker that exits without returning a result is no longer counted as a success, and its log is kept. The underlying hang (#1130) and startup exit (#1145) remain open for investigation.
30+
31+
**Workaround:** For repositories containing large binary, media, or model directories, exclude those paths with `.cbmignore` before indexing (see [`.cbmignore` documentation](cbmignore.md)). From v0.10.5, the worker log names the in-flight file; if indexing still fails on v0.11.0 or newer, attach that log to #1130 or #1145.
32+
33+
**Tracking:** #1130, #1132, #1145.
34+
35+
## Antigravity 2.0 configuration not picked up
36+
37+
**Symptom:** Installation completes but Antigravity 2.0 does not see the MCP server or hooks, or the environment is detected as Gemini-CLI; duplicate large binaries may also be left on disk.
38+
39+
**Affected versions:** All releases through v0.12.1 when neither detection signal below is present (v0.9.x checks only for `~/.gemini/antigravity-cli`; from v0.10.0, `antigravity` on PATH also counts). The duplicate binary left behind by `install.ps1` affects v0.9.x and earlier (fixed in v0.10.0).
40+
41+
**Workaround:** Antigravity is configured only when `~/.gemini/antigravity-cli` exists or `antigravity` is on PATH; the target is `~/.gemini/config/mcp_config.json`, and no hooks are installed for it. If neither signal is present, the machine is treated as Gemini-CLI. From v0.10.0, `install.ps1` keeps a single binary; running `codebase-memory-mcp install` manually without `--dir` can still create a second copy in `~/.local/bin`.
42+
43+
**Tracking:** #1161.
44+
45+
## OpenCode installed but not detected
46+
47+
**Symptom:** `codebase-memory-mcp install` detects other clients but skips OpenCode on Windows.
48+
49+
**Affected versions:** v0.9.x and earlier detect OpenCode only through `opencode` on PATH. v0.10.0 also detects its configuration (the config file, `%USERPROFILE%\.config\opencode\`, or `OPENCODE_CONFIG_DIR`), and v0.12.0 also detects its data folder `%USERPROFILE%\.local\share\opencode\`, which the OpenCode CLI and the Desktop app both create, so detection no longer depends on PATH. In v0.12.1 and earlier, a PATH longer than 4 KB hides every CLI from detection, and npm, mise and scoop shim folders are not searched; both are fixed after v0.12.1 (#2381).
50+
51+
**Workaround:** On v0.12.0 or newer, start OpenCode once (CLI or Desktop app) so that its data folder exists, then re-run `codebase-memory-mcp install`. On v0.10.x or v0.11.0, make sure `%USERPROFILE%\.config\opencode\` exists (or point `OPENCODE_CONFIG` at an existing config file, or `OPENCODE_CONFIG_DIR` at an existing folder), then re-run `codebase-memory-mcp install`. On v0.9.x, `opencode` must be on PATH; upgrading with `install.ps1` is the simpler fix.
52+
53+
**Tracking:** #1167.
54+
55+
---
56+
57+
When a release resolves one of these issues, update or remove the corresponding entry rather than letting this page become a second issue tracker.

‎internal/cbm/extract_calls.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,11 +2249,15 @@ static char *extract_callee_name(CBMArena *a, TSNode node, const char *source, C
22492249
// method is `new`. The constructor body lives in `initialize`, so a callee
22502250
// of "new" never resolves. Redirect to the receiver type name so the call
22512251
// links to the class/constructor like every other language's `new T()`.
2252+
// Scope-resolved receivers (`Admin::User.new`) get the same treatment —
2253+
// the callee carries the full constant path ("Admin::User"), whose bare
2254+
// leaf ("User") is what resolution joins on.
22522255
if (lang == CBM_LANG_RUBY) {
22532256
TSNode m = ts_node_child_by_field_name(node, TS_FIELD("method"));
22542257
TSNode recv = ts_node_child_by_field_name(node, TS_FIELD("receiver"));
22552258
if (!ts_node_is_null(m) && !ts_node_is_null(recv) &&
2256-
strcmp(ts_node_type(recv), "constant") == 0) {
2259+
(strcmp(ts_node_type(recv), "constant") == 0 ||
2260+
strcmp(ts_node_type(recv), "scope_resolution") == 0)) {
22572261
char *mt = cbm_node_text(a, m, source);
22582262
if (mt && strcmp(mt, "new") == 0) {
22592263
char *rt = cbm_node_text(a, recv, source);

‎scripts/ci/generate-sbom.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"packages": [
4141
{"SPDXID": "SPDXRef-Package-sqlite3", "name": "sqlite3", "versionInfo": "3.51.3", "licenseDeclared": "blessing", "downloadLocation": "https://sqlite.org", "filesAnalyzed": False},
4242
{"SPDXID": "SPDXRef-Package-yyjson", "name": "yyjson", "versionInfo": "0.12.0", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/ibireme/yyjson", "filesAnalyzed": False},
43-
{"SPDXID": "SPDXRef-Package-mimalloc", "name": "mimalloc", "versionInfo": "3.3.2", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/microsoft/mimalloc", "filesAnalyzed": False},
43+
{"SPDXID": "SPDXRef-Package-mimalloc", "name": "mimalloc", "versionInfo": "3.5.3", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/microsoft/mimalloc", "filesAnalyzed": False},
4444
{"SPDXID": "SPDXRef-Package-xxhash", "name": "xxhash", "versionInfo": "0.8.3", "licenseDeclared": "BSD-2-Clause", "downloadLocation": "https://github.com/Cyan4973/xxHash", "filesAnalyzed": False},
4545
{"SPDXID": "SPDXRef-Package-tre", "name": "tre", "versionInfo": "0.8.0", "licenseDeclared": "BSD-2-Clause", "downloadLocation": "https://github.com/laurikari/tre", "filesAnalyzed": False},
4646
{"SPDXID": "SPDXRef-Package-tree-sitter", "name": "tree-sitter", "versionInfo": "0.24.4", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/tree-sitter/tree-sitter", "filesAnalyzed": False},

‎scripts/test.sh‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,14 @@ make -j"$NPROC" -f Makefile.cbm cbm TEST_SEAMS=1 ${MAKE_ARGS[@]+"${MAKE_ARGS[@]}
496496
WATCHDOG_BINARY="$ROOT/$BUILD_DIR/codebase-memory-mcp"
497497
CBM_TEST_BINARY="$WATCHDOG_BINARY" bash "$ROOT/tests/test_parent_watchdog.sh"
498498

499+
# Step 5-alloc: the production allocator object Step 5 just built. The unit
500+
# suites link mimalloc's debug build without the global override, so they cannot
501+
# see free(NULL) before the allocator's constructor (mimalloc #1341, PR #2562)
502+
# or the vendored local patches; this links small fixtures against
503+
# prod_mimalloc.o itself.
504+
echo "=== Step 5-alloc: production allocator contract (mimalloc #1341 + local patches) ==="
505+
bash "$ROOT/tests/test_prod_allocator_contract.sh" "$ROOT/$BUILD_DIR"
506+
499507
# Step 5a: that watchdog is also the SMALLEST-stack thread in the image, which
500508
# makes it the first casualty when static TLS grows — glibc takes the TLS block
501509
# out of each thread's own stack allocation. Checked here, against the binary

0 commit comments

Comments
 (0)