Skip to content

Commit 18fa997

Browse files
committed
Replace vmem with mimalloc global allocator, add extraction-phase prescan, fix __init__.py QN collision
Memory management: - Vendor mimalloc v2.1.9 as global allocator (MI_OVERRIDE=1 in prod) - New mem.h/mem.c: RSS-based budget tracking via mi_process_info() - Remove vmem.c/vmem.h (mmap-based budget tracking) - Remove slab tier2 bump allocator (~300 LOC); >64B goes to mimalloc - Slab tier1 pages from malloc (= mimalloc) instead of vmem - Arena blocks from malloc instead of vmem - Budget raised from 35% to 50% RAM (no more untracked C++ heap) Extraction-phase prescan (eliminates disk re-reads): - HTTP call sites: keyword check + URL extraction during extraction - HTTP routes: decorator + source-based extraction during extraction - Config file refs: regex scan during extraction - httplinks: 41.8s → 13ms on Linux kernel (3,212x faster) - configlink: 41.4s → 0.8s on Linux kernel (54x faster) - Linux kernel fast-mode total: 2m38s → 1m18s Bug fixes: - __init__.py Module QN no longer collides with Folder QN - index.ts same fix for JS/TS packages - 13 regression tests for QN collision at FQN + extraction layers - search_graph/search_code default limit raised from 10 to 500k - Resolve all clang-tidy, cppcheck, and clang-format warnings Repo cleanup: - tree-sitter-form, tree-sitter-magma moved to tools/ - .gitignore: build/, node_modules/, graph-ui/dist/, TEST_PLAN.md
1 parent 0d216c7 commit 18fa997

208 files changed

Lines changed: 122316 additions & 48635 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.

.clang-tidy

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ Checks: >
1515
portability-*,
1616
readability-*,
1717
clang-analyzer-*,
18+
-misc-no-recursion,
19+
-bugprone-multi-level-implicit-pointer-conversion,
20+
-bugprone-branch-clone,
21+
-bugprone-command-processor,
22+
-readability-avoid-nested-conditional-operator,
23+
-readability-redundant-casting,
24+
-bugprone-implicit-widening-of-multiplication-result,
25+
-bugprone-unchecked-string-to-number-conversion,
26+
-bugprone-easily-swappable-parameters,
27+
-clang-analyzer-core.CallAndMessage,
28+
-clang-analyzer-security.ArrayBound,
29+
-clang-analyzer-unix.Malloc,
30+
-clang-analyzer-optin.portability.UnixAPI,
31+
-clang-analyzer-core.NullPointerArithm,
32+
-performance-no-int-to-ptr,
33+
-concurrency-mt-unsafe,
34+
-cert-err33-c,
1835
1936
WarningsAsErrors: '*'
2037

@@ -27,11 +44,11 @@ CheckOptions:
2744
# C idiom: if (!ptr), if (count) are standard
2845
readability-implicit-bool-conversion.AllowIntegerConditions: true
2946
readability-implicit-bool-conversion.AllowPointerConditions: true
30-
# Systems C uses bit shifts, buffer sizes, hash constants
31-
readability-magic-numbers.IgnoredIntegerValues: "1;2;3;4;5;6;7;8;9;10;12;16;20;24;32;48;64;100;128;200;256;512;1000;1024;2048;4096;8192;16384;32768;65536"
32-
readability-magic-numbers.IgnoredFloatingPointValues: "0.0;0.5;1.0;2.0;100.0"
33-
# Tree-sitter parser/resolver functions have deep switch statements
34-
readability-function-cognitive-complexity.Threshold: 200
47+
# Systems C uses bit shifts, buffer sizes, hash constants, protocol sizes
48+
readability-magic-numbers.IgnoredIntegerValues: "1;2;3;4;5;6;7;8;9;10;11;12;14;15;16;20;24;32;48;64;100;128;200;256;493;512;755;1000;1024;1040;2048;4096;8192;16384;32768;65536;500000;1000000;1000000000"
49+
readability-magic-numbers.IgnoredFloatingPointValues: "0.0;0.25;0.5;0.7;0.75;0.8;0.85;0.9;0.95;1.0;2.0;100.0;1e308"
50+
# Cypher parser + tree-sitter resolver have deeply nested execution logic
51+
readability-function-cognitive-complexity.Threshold: 250
3552
readability-function-size.StatementThreshold: 400
3653
readability-function-size.LineThreshold: 800
3754

.github/workflows/dry-run.yml

Lines changed: 32 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,106 +7,69 @@ permissions:
77
contents: read
88

99
jobs:
10-
lint:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
15-
- uses: actions/setup-go@v5
16-
with:
17-
go-version: "1.26"
18-
19-
- uses: golangci/golangci-lint-action@v7
20-
with:
21-
version: v2.10
22-
args: --timeout=5m
23-
2410
test-unix:
25-
needs: [lint]
2611
strategy:
2712
matrix:
2813
include:
2914
- os: ubuntu-latest
30-
goos: linux
31-
goarch: amd64
15+
arch: amd64
3216
- os: ubuntu-24.04-arm
33-
goos: linux
34-
goarch: arm64
17+
arch: arm64
3518
- os: macos-14
36-
goos: darwin
37-
goarch: arm64
19+
arch: arm64
3820
- os: macos-15-intel
39-
goos: darwin
40-
goarch: amd64
21+
arch: amd64
4122
runs-on: ${{ matrix.os }}
4223
steps:
4324
- uses: actions/checkout@v4
4425

45-
- uses: actions/setup-go@v5
46-
with:
47-
go-version: "1.26"
26+
- name: Install deps (Ubuntu)
27+
if: startsWith(matrix.os, 'ubuntu')
28+
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev zlib1g-dev
4829

49-
- name: Run tests
50-
run: go test ./...
30+
- name: Run C tests (ASan + UBSan)
31+
run: make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm test
5132

52-
- name: Build binary
53-
run: |
54-
CGO_ENABLED=1 go build \
55-
-o codebase-memory-mcp \
56-
./cmd/codebase-memory-mcp/
57-
58-
- name: Smoke test
59-
run: bash scripts/smoke-test.sh ./codebase-memory-mcp
33+
- name: Build standard binary
34+
run: make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm cbm
6035

61-
test-asan:
62-
needs: [lint]
63-
runs-on: ubuntu-latest
64-
steps:
65-
- uses: actions/checkout@v4
36+
- name: Smoke test (standard)
37+
run: |
38+
./build/c/codebase-memory-mcp --version
39+
echo '{}' | timeout 3 ./build/c/codebase-memory-mcp 2>&1 || true
40+
echo "Smoke test passed"
6641
67-
- uses: actions/setup-go@v5
42+
- uses: actions/setup-node@v4
6843
with:
69-
go-version: "1.26"
44+
node-version: "22"
7045

71-
- name: Test with AddressSanitizer
72-
env:
73-
CGO_CFLAGS: "-fsanitize=address -fno-omit-frame-pointer"
74-
CGO_LDFLAGS: "-fsanitize=address"
75-
run: go test -count=1 -timeout=10m ./...
46+
- name: Build UI binary
47+
run: make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm cbm-with-ui
7648

77-
- name: Memory stability check
78-
run: go test -run TestMemoryStability -v -count=1 -timeout=5m ./internal/pipeline/
49+
- name: Smoke test (UI)
50+
run: |
51+
./build/c/codebase-memory-mcp --version
52+
echo "UI binary smoke test passed"
7953
8054
test-windows:
81-
needs: [lint]
8255
runs-on: windows-latest
8356
steps:
8457
- uses: actions/checkout@v4
8558

86-
- uses: actions/setup-go@v5
87-
with:
88-
go-version: "1.26"
89-
9059
- uses: msys2/setup-msys2@v2
9160
with:
9261
msystem: UCRT64
9362
path-type: inherit
94-
install: mingw-w64-ucrt-x86_64-gcc
63+
install: >-
64+
mingw-w64-ucrt-x86_64-gcc
65+
mingw-w64-ucrt-x86_64-sqlite3
66+
mingw-w64-ucrt-x86_64-zlib
67+
make
9568
96-
- name: Run tests
69+
- name: Build standard binary
9770
shell: msys2 {0}
98-
run: |
99-
which go
100-
go version
101-
go test ./...
102-
103-
- name: Build binary
104-
shell: msys2 {0}
105-
run: |
106-
CGO_ENABLED=1 CC=gcc go build \
107-
-o codebase-memory-mcp.exe \
108-
./cmd/codebase-memory-mcp/
71+
run: make -j$(nproc) -f Makefile.cbm cbm
10972

11073
- name: Smoke test
11174
shell: msys2 {0}
112-
run: bash scripts/smoke-test.sh ./codebase-memory-mcp.exe
75+
run: ./build/c/codebase-memory-mcp.exe --version || ./build/c/codebase-memory-mcp --version

.github/workflows/release.yml

Lines changed: 76 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "Release version (e.g. v0.0.2)"
7+
description: "Release version (e.g. v0.8.0)"
88
required: true
99
type: string
1010
release_notes:
@@ -21,22 +21,7 @@ permissions:
2121
contents: write
2222

2323
jobs:
24-
lint:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/checkout@v4
28-
29-
- uses: actions/setup-go@v5
30-
with:
31-
go-version: "1.26"
32-
33-
- uses: golangci/golangci-lint-action@v7
34-
with:
35-
version: v2.10
36-
args: --timeout=5m
37-
3824
build-unix:
39-
needs: [lint]
4025
strategy:
4126
matrix:
4227
include:
@@ -56,81 +41,114 @@ jobs:
5641
steps:
5742
- uses: actions/checkout@v4
5843

59-
- uses: actions/setup-go@v5
60-
with:
61-
go-version: "1.26"
44+
- name: Install deps (Ubuntu)
45+
if: startsWith(matrix.os, 'ubuntu')
46+
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev zlib1g-dev
6247

63-
- name: Run tests
64-
run: go test ./...
48+
- name: Run C tests
49+
run: make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm test
6550

66-
- name: Build binary
51+
# ── Standard binary (no UI, no Node.js needed) ──
52+
- name: Build standard binary
6753
env:
6854
VERSION: ${{ inputs.version }}
6955
run: |
70-
# Strip leading 'v' — version var should be bare semver (e.g. 0.4.0)
7156
CLEAN_VERSION="${VERSION#v}"
72-
CGO_ENABLED=1 go build \
73-
-ldflags "-X main.version=$CLEAN_VERSION" \
74-
-o codebase-memory-mcp \
75-
./cmd/codebase-memory-mcp/
57+
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm cbm \
58+
CFLAGS_EXTRA="-DCBM_VERSION=\"\\\"$CLEAN_VERSION\\\"\""
7659
77-
- name: Smoke test
78-
run: bash scripts/smoke-test.sh ./codebase-memory-mcp
60+
- name: Smoke test (standard)
61+
run: ./build/c/codebase-memory-mcp --version
62+
63+
- name: Archive standard binary
64+
run: |
65+
tar -czf codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz \
66+
-C build/c codebase-memory-mcp
67+
68+
# ── UI binary (embedded frontend, needs Node.js) ──
69+
- uses: actions/setup-node@v4
70+
with:
71+
node-version: "22"
72+
73+
- name: Build UI binary
74+
env:
75+
VERSION: ${{ inputs.version }}
76+
run: |
77+
CLEAN_VERSION="${VERSION#v}"
78+
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) -f Makefile.cbm cbm-with-ui \
79+
CFLAGS_EXTRA="-DCBM_VERSION=\"\\\"$CLEAN_VERSION\\\"\""
7980
80-
- name: Create archive
81-
run: tar -czf codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz codebase-memory-mcp
81+
- name: Smoke test (UI)
82+
run: ./build/c/codebase-memory-mcp --version
83+
84+
- name: Archive UI binary
85+
run: |
86+
tar -czf codebase-memory-mcp-ui-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz \
87+
-C build/c codebase-memory-mcp
8288
8389
- uses: actions/upload-artifact@v4
8490
with:
85-
name: codebase-memory-mcp-${{ matrix.goos }}-${{ matrix.goarch }}
91+
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
8692
path: "*.tar.gz"
8793

8894
build-windows:
89-
needs: [lint]
9095
runs-on: windows-latest
9196
steps:
9297
- uses: actions/checkout@v4
9398

94-
- uses: actions/setup-go@v5
95-
with:
96-
go-version: "1.26"
97-
9899
- uses: msys2/setup-msys2@v2
99100
with:
100101
msystem: UCRT64
101102
path-type: inherit
102-
install: mingw-w64-ucrt-x86_64-gcc
103+
install: >-
104+
mingw-w64-ucrt-x86_64-gcc
105+
mingw-w64-ucrt-x86_64-sqlite3
106+
mingw-w64-ucrt-x86_64-zlib
107+
make
108+
109+
# ── Standard binary ──
110+
- name: Build standard binary
111+
shell: msys2 {0}
112+
env:
113+
VERSION: ${{ inputs.version }}
114+
run: |
115+
CLEAN_VERSION="${VERSION#v}"
116+
make -j$(nproc) -f Makefile.cbm cbm \
117+
CFLAGS_EXTRA="-DCBM_VERSION=\"\\\"$CLEAN_VERSION\\\"\""
103118
104-
- name: Run tests
119+
- name: Smoke test
105120
shell: msys2 {0}
121+
run: ./build/c/codebase-memory-mcp --version
122+
123+
- name: Archive standard binary
124+
shell: pwsh
106125
run: |
107-
which go
108-
go version
109-
go test ./...
126+
Copy-Item build/c/codebase-memory-mcp -Destination codebase-memory-mcp.exe
127+
Compress-Archive -Path codebase-memory-mcp.exe -DestinationPath codebase-memory-mcp-windows-amd64.zip
110128
111-
- name: Build binary
129+
# ── UI binary ──
130+
- uses: actions/setup-node@v4
131+
with:
132+
node-version: "22"
133+
134+
- name: Build UI binary
112135
shell: msys2 {0}
113136
env:
114137
VERSION: ${{ inputs.version }}
115138
run: |
116-
# Strip leading 'v' — version var should be bare semver (e.g. 0.4.0)
117139
CLEAN_VERSION="${VERSION#v}"
118-
CGO_ENABLED=1 CC=gcc go build \
119-
-ldflags "-X main.version=$CLEAN_VERSION -extldflags '-static'" \
120-
-o codebase-memory-mcp.exe \
121-
./cmd/codebase-memory-mcp/
140+
make -j$(nproc) -f Makefile.cbm cbm-with-ui \
141+
CFLAGS_EXTRA="-DCBM_VERSION=\"\\\"$CLEAN_VERSION\\\"\""
122142
123-
- name: Smoke test
124-
shell: msys2 {0}
125-
run: bash scripts/smoke-test.sh ./codebase-memory-mcp.exe
126-
127-
- name: Create archive
143+
- name: Archive UI binary
128144
shell: pwsh
129-
run: Compress-Archive -Path codebase-memory-mcp.exe -DestinationPath codebase-memory-mcp-windows-amd64.zip
145+
run: |
146+
Copy-Item build/c/codebase-memory-mcp -Destination codebase-memory-mcp.exe -Force
147+
Compress-Archive -Path codebase-memory-mcp.exe -DestinationPath codebase-memory-mcp-ui-windows-amd64.zip
130148
131149
- uses: actions/upload-artifact@v4
132150
with:
133-
name: codebase-memory-mcp-windows-amd64
151+
name: binaries-windows-amd64
134152
path: "*.zip"
135153

136154
release:
@@ -145,6 +163,9 @@ jobs:
145163
with:
146164
merge-multiple: true
147165

166+
- name: List artifacts
167+
run: ls -la *.tar.gz *.zip
168+
148169
- name: Generate checksums
149170
run: sha256sum *.tar.gz *.zip > checksums.txt
150171

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ Thumbs.db
3333
# Local project memory (Claude Code auto-memory)
3434
memory/
3535
reference/
36+
37+
# Build artifacts
38+
build/
39+
node_modules/
40+
graph-ui/dist/
41+
42+
# Generated reports
43+
BENCHMARK_REPORT.md
44+
TEST_PLAN.md

0 commit comments

Comments
 (0)