Skip to content

Commit 1237096

Browse files
committed
Merge origin/main into feat/nextjs-app-router-routes
Main has used semantic index versions 10 and 11 since this branch took 10, so the Next.js App Router routes move to version 12 with their own history entry: an index main wrote at 11 rebuilds once for the new Routes. pipeline_nextjs_semantic_upgrade_issue759 now starts from a version-11 index. The other conflicts were tests both sides added at the same place; both kept. Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
2 parents da5db34 + a3831c9 commit 1237096

152 files changed

Lines changed: 16015 additions & 5333 deletions

File tree

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

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

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

‎README.md‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,15 @@ overwrite user-modified agents.
694694

695695
| Agent | Activation | MCP config | Durable context / augmentation |
696696
|-------|------------|------------|--------------------------------|
697-
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, and post-`Read` coverage |
698-
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart` |
697+
| Claude Code | Detected | `~/.claude.json` | Skill + three exact-tool graph agents; `SessionStart`, `SubagentStart`, non-blocking `PreToolUse` for `Grep`/`Glob`/`Bash`, post-`Read` coverage, and a drift note after repeated searches without a graph call |
698+
| Codex CLI | Detected | `$CODEX_HOME/config.toml` | Managed `AGENTS.md` activation pointer, skill, three read-only agents; `SessionStart` + `SubagentStart`, `PreToolUse` graph lookup for `Bash` searches |
699699
| Gemini CLI | Detected | `.gemini/settings.json` | `GEMINI.md`, three explicit read/graph-tool subagents; `BeforeTool`, `AfterTool` `read_file` coverage, and `SessionStart` |
700700
| Zed | Detected | platform `settings.json` (JSONC) | `AGENTS.md` + shared skill |
701701
| OpenCode | Detected | `$OPENCODE_CONFIG` or resolved global config | `AGENTS.md`, skill, three deny-by-default read-only agents; plugin adds grep/glob graph lookup, post-`read` coverage, first-tool-result session context, and post-compaction reinjection |
702702
| Antigravity | Detected | `.gemini/config/mcp_config.json` | `.gemini/GEMINI.md` |
703703
| Aider | Detected | none | `CONVENTIONS.md` via `.aider.conf.yml` |
704704
| KiloCode | Detected | `.config/kilo/kilo.jsonc` | Rule + three graph-tool subagents with deny-by-default permissions |
705-
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart` |
705+
| VS Code | Detected | platform `Code/User/mcp.json` | `~/.copilot/skills`, three read-only agents, `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
706706
| Cursor | Detected | `.cursor/mcp.json` | Skill + three read-only parent-handoff agents; context hooks withheld because session injection races and `readonly` blocks MCP |
707707
| Windsurf | Detected | `~/.codeium/windsurf/mcp_config.json` | Always-on `global_rules.md` |
708708
| Augment / Auggie | Detected | `~/.augment/settings.json` | Rule, three read-only handoff subagents, `SessionStart` + post-`view` coverage |
@@ -714,7 +714,7 @@ overwrite user-modified agents.
714714
| Cline | Detected | `~/.cline/mcp.json` + `${CLINE_DATA_DIR:-~/.cline/data}/settings/cline_mcp_settings.json` | Rule + skill; automatic file hooks withheld because they auto-activate and their output is not reliably consumed; child agents cannot use MCP |
715715
| Warp | Detected, skill only | UI, Warp Drive, or per invocation (manual) | Shared `~/.agents/skills/codebase-memory/SKILL.md` |
716716
| Qwen Code | Detected | `.qwen/settings.json` | `QWEN.md`, skill, three explicit read/graph-tool agents; `SessionStart`, `SubagentStart`, and post-`ReadFile` coverage |
717-
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart` |
717+
| GitHub Copilot CLI | Detected | `$COPILOT_HOME/mcp-config.json` | Instructions, skill, three read-only agents; `sessionStart` + `subagentStart`, post-search `PostToolUse` graph lookup |
718718
| Factory Droid | Detected | `.factory/mcp.json` | `AGENTS.md`, skill, three droids with exact per-tier graph-tool lists (without additive whole-server exposure); `SessionStart` + post-`Read` coverage on macOS/Linux, withheld on Windows |
719719
| Crush | Detected | `.config/crush/crush.json` | Managed context path with explicit parent-to-child handoff |
720720
| Goose | Detected | `.config/goose/config.yaml` | `.goosehints` |
@@ -751,7 +751,14 @@ Hooks installed by this project are fail-open and context-only. Claude Code's
751751
`PreToolUse` observes `Grep`/`Glob`/`Bash` and injects matching graph symbols as
752752
`additionalContext`; `PostToolUse` on `Read` adds targeted coverage context when
753753
the graph could not fully parse or index that file. It never denies or replaces
754-
the requested tool call.
754+
the requested tool call. Codex CLI's `PreToolUse` on `Bash` gives its shell
755+
searches the same context. GitHub Copilot CLI and VS Code's Copilot runtime get
756+
it after the search: their `preToolUse` can only decide permissions, so a
757+
`PostToolUse` entry for `Bash`, `Grep` and `Glob` appends the graph symbols to
758+
the tool result. In Claude Code, once a session has run three searches with no
759+
codebase-memory-mcp tool call, the next augmentation adds one line saying so;
760+
the next note comes after six searches, then twelve. Claude's `PostToolUse`
761+
entry also matches the graph tools, and a graph tool call resets the count.
755762

756763
Claude Code, Codex CLI, Qwen Code, GitHub Copilot CLI, and VS Code's Copilot
757764
runtime receive paired session/subagent context where the vendor exposes a
@@ -1030,6 +1037,8 @@ SQLite databases stored at `~/.cache/codebase-memory-mcp/`. Persists across rest
10301037

10311038
## Troubleshooting
10321039

1040+
Windows users: see [Windows troubleshooting](docs/WINDOWS_TROUBLESHOOTING.md) for versioned known issues and workarounds.
1041+
10331042
| Problem | Fix |
10341043
|---------|-----|
10351044
| `/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/CONFIGURATION.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,15 @@ root because they are too broad or too sensitive to index as a unit:
245245
- a credential directory at any depth — `.ssh`, `.aws`, `.gnupg`, `.kube`,
246246
`.docker`, `.netrc`, `.git-credentials`, `.password-store`, macOS `Keychains`.
247247

248+
A single top-level directory can still be indexed as one root on purpose, for
249+
example a container or build machine that keeps its project in `/work`, `/app` or
250+
`/src`, by approving that exact path in a terminal:
251+
`codebase-memory-mcp allow-root --approve-broad /work`. The approval is recorded
252+
like any other allowed root, listed as `(approved broad)` by `allow-root --list`,
253+
and covers no other top-level directory; as with any recorded root, indexing is
254+
then confined to the recorded roots. Filesystem, drive and share roots cannot be
255+
approved.
256+
248257
Two limits are worth stating plainly. This constrains *scope*, not
249258
*sensitivity*: inside a root that is allowed, every file the process can read may
250259
be indexed and later returned. And the credential list is a denylist, so it

‎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/cbm.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "foundation/hash_table.h" // CBMHashTable — crash-supervisor quarantine set
3131
#include "foundation/str_util.h" // cbm_json_escape — variants file_path
3232
#include "tree_sitter/api.h" // TSParser, TSNode, TSTree, TSInput, TSLanguage, TSPoint, TSParseOptions, TSParseState
33+
#include "foundation/platform.h"
3334
#include "foundation/constants.h"
3435
#include "mimalloc.h" // mi_malloc/mi_calloc/mi_realloc/mi_free/mi_usable_size — bind 3rd-party allocators (#424)
3536
#if defined(CBM_BIND_TS_ALLOCATOR) && CBM_BIND_TS_ALLOCATOR
@@ -1259,7 +1260,9 @@ static int count_params_from_signature(const char *sig) {
12591260
* unlucky in-flight file is never quarantined alone. The env var is set
12601261
* solely by the supervisor during recovery — a no-op on normal runs. */
12611262
static void cbm_index_mark(const char *rel_path, char event) {
1262-
const char *mf = getenv("CBM_INDEX_MARKER_FILE");
1263+
char marker_path[CBM_SZ_4K];
1264+
const char *mf =
1265+
cbm_safe_getenv("CBM_INDEX_MARKER_FILE", marker_path, sizeof(marker_path), NULL);
12631266
if (!mf || !mf[0] || !rel_path || !rel_path[0]) {
12641267
return;
12651268
}
@@ -1296,7 +1299,9 @@ enum { CBM_QSET_UNINIT = 0, CBM_QSET_INITING = 1, CBM_QSET_INITED = 2 };
12961299
static atomic_int g_quarantine_state = CBM_QSET_UNINIT;
12971300

12981301
static void cbm_quarantine_load(void) {
1299-
const char *qf = getenv("CBM_INDEX_QUARANTINE_FILE");
1302+
char quarantine_path[CBM_SZ_4K];
1303+
const char *qf = cbm_safe_getenv("CBM_INDEX_QUARANTINE_FILE", quarantine_path,
1304+
sizeof(quarantine_path), NULL);
13001305
if (!qf || !qf[0]) {
13011306
return; /* normal path: empty set */
13021307
}

‎internal/cbm/cbm.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ typedef struct {
313313
* change of all, store_impact.h follow_variant_keys). NULL on every other
314314
* definition. Tail field: zero-init stays valid. */
315315
const char *variant_key;
316+
/* Go only (#2033): the raw aliased type text of an identity alias
317+
* `type A = B` ("B"). Carried to the cross-file registries so a method
318+
* call on A from another file follows the alias to B's method set. NULL
319+
* for a defined type `type A B` (its method set is its own) and in every
320+
* other language. Tail field: zero-init stays valid. */
321+
const char *alias_target;
316322
} CBMDefinition;
317323

318324
/* Argument captured from a call expression */

‎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);

0 commit comments

Comments
 (0)