Commit Graph
26 Commits
Author SHA1 Message Date
Andrew Hundt ce6d970f1b fix(autotune): fix CWD bug, race condition, and update CBM ground truth
Three bugs fixed in autotune.py:

1. CWD bug: binary uses getcwd() (not rootUri) for session_root.
   _send_batch now passes cwd=repo_root to subprocess so architecture
   queries return results for the correct project.

2. Race condition: delete_project_db() before an MCP session triggered
   the background autoindex thread which raced with index_repository,
   causing isError=true. Removed the deletion — index_repository forces
   a full reindex by itself.

3. CBM ground truth was wrong: used C in-degree (cbm_arena_alloc in-degree
   21) but PageRank is nearly uniform for CBM's C graph (~0.000035 for all).
   Updated to functions verified high by PageRank: cbm_go_stdlib_register,
   cbm_extract_imports, cbm_levenshtein_distance, cbm_path_match_score, etc.

Added exclude_ui_tests and calls_boost_excl_tests experiments.

Final scores (9/30 vs 5/30 before fixes):
  rtk:    5/10 — tokenize, resolved_command, check_for_hook, try_route_native_command
  autorun: 2/10 — session_state, SessionStateManager (Path stdlib bug inflates top slots)
  cbm:    1-2/10 — architecture IS improved, C/Go code shown instead of TypeScript UI

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-26 05:37:40 -04:00
Andrew Hundt 52d2445f8b autotune.py: set DEFAULTS to best experiment results (calls_boost_excl_tests)
Previous defaults: edge_weight_calls=1.0, edge_weight_usage=0.7,
key_functions_exclude="" (no exclusions).

What changed:
- scripts/autotune.py DEFAULTS: edge_weight_calls 1.0 → 2.0 (call edges
  are the strongest signal for production importance)
- scripts/autotune.py DEFAULTS: edge_weight_usage 0.7 → 0.3 (type-reference
  edges add noise, dampening improves ranking signal)
- scripts/autotune.py DEFAULTS: key_functions_exclude "" → "graph-ui/**,
  tools/**,scripts/**,tests/**" (excluding non-production paths surfaces core
  library functions instead of test helpers)

Why: autotune run on 2026-03-26 scored calls_boost_excl_tests at 6/30 across
3 repos (codebase-memory-mcp, autorun, rtk), best of 8 experiments. Baseline
scored 0/30. These defaults are now the baseline that experiments diverge from,
so future autotune runs search the config space around the current best.

  Testable: python3 scripts/autotune.py  (baseline_25 now starts from these values)

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-26 05:31:05 -04:00
Andrew Hundt 2c255f0430 autotune.py: fix PageRank recompute, persistent MCP session, JSON results, CLI params
Previous behavior: autotune set config keys but never triggered PageRank recompute
between experiments — all experiments read stale stored scores, producing identical
results. The binary also got SIGKILL'd on macOS 25+ due to invalidated ad-hoc
signature after `cp` during install.

What changed:
- scripts/autotune.py: replace query_architecture() (async REQUIRE_STORE reindex)
  with index_and_query_architecture() — opens one persistent stdio MCP session per
  repo per experiment sending 3 sequential messages: initialize → tools/call
  index_repository (synchronous, blocks until full pipeline+PageRank completes with
  current edge weights) → resources/read codebase://architecture
- scripts/autotune.py: add project_name_from_path() mirroring cbm_project_name_from_path()
  from src/pipeline/fqn.c, and delete_project_db() to remove stale DBs
- scripts/autotune.py: add _send_batch() env+cwd params; pass CBM_TOOL_MODE=classic
  so index_repository tool is available in MCP session
- scripts/autotune.py: add --top-matches (default 10) and --key-count (default 25)
  CLI params; show matched expected names + top-N per repo in output
- scripts/autotune.py: default timeout 60s → 1200s (indexing takes ~40s per repo)
- scripts/autotune.py: add exclude_ui_tests experiment; rename calls_boost_excl →
  calls_boost_excl_tests with tests/** added to exclude list
- scripts/autotune.py: save every run to scripts/autotune_results.json (appended,
  with timestamp/binary/repos/experiments/best fields)
- scripts/autotune.py: show progress bar (█/░) and ◀ BEST marker in final report
- .gitignore: add scripts/autotune_results.json (generated artifact, not tracked)

Why: edge weights and PageRank iterations are only applied at index time via
cbm_pagerank_compute_with_config(); querying a DB indexed with old weights produces
wrong rankings regardless of config changes. Full reindex per experiment is required.
Also fixes macOS 25+ SIGKILL by rebuilding binary (Makefile.cbm re-signs with
codesign --force --sign - after install).

First run result: calls_boost_excl_tests scores 6/30 (best), baseline 0/30.
  Testable: python3 scripts/autotune.py

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-26 05:30:26 -04:00
Andrew Hundt 1646f96988 feat(config,ranking): parameterize limits, enrich config docs, add autotune
Fixes codebase://architecture returning only 10 results all from graph-ui
by wiring hardcoded limits through the config system and raising defaults to 25.

Key changes:
- mcp.c: add key_functions_count config (default 25); wire into
  build_key_functions_sql (was hardcoded LIMIT 10 at line 4317) and
  build_resource_architecture call site
- mcp.c: add arch_hotspot_limit config (default 25); wire into classic
  get_architecture tool handler
- store.c/store.h: raise CBM_ARCH_HOTSPOT_DEFAULT_LIMIT 10->25; add
  hotspot_limit param to cbm_store_get_architecture
- store.c/store.h: add sort_by=calls (ORDER BY calls_in+calls_out DESC)
  and sort_by=linkrank (ORDER BY linkrank_in DESC) dispatch cases;
  add degree_mode config (weighted|unweighted|calls_only) for
  min_degree/max_degree filter column selection
- watcher.c/watcher.h: add poll_base_ms/poll_max_ms to struct cbm_watcher;
  change cbm_watcher_run and cbm_watcher_poll_interval_ms signatures to
  accept base_ms/max_ms params (0=defaults); wire watcher_poll_base_ms and
  watcher_poll_max_ms config keys through main.c
- cli.h: extend cbm_config_entry_t with range and guidance fields (5->7)
- cli.c: replace entire CBM_CONFIG_REGISTRY with 7-field entries for all 32
  config keys with broadest feasible ranges and actionable guidance strings;
  update config list/get/help display to print [range] + guidance per entry
- scripts/autotune.py: new standalone Python 3.9+ script that sends JSON-RPC
  directly to the binary via stdin/stdout, tries 7 experiments, scores
  against expected top-10 ground truth for 3 repos, resets config on exit
- tests: update all callers of cbm_store_get_architecture (pass 0 for
  hotspot_limit) and cbm_watcher_poll_interval_ms (pass 0,0 for defaults)

All 2238 tests pass.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-26 04:40:13 -04:00
Martin Vogel 0f3c772014 Fix Windows smoke: convert MSYS2 POSIX paths for native binary
MSYS2 mktemp returns /tmp/tmp.XXX but the Windows binary can't resolve
POSIX paths. Use cygpath -m to convert to C:/msys64/tmp/tmp.XXX which
works in both MSYS2 shell and Windows file APIs.
2026-03-19 12:29:54 +01:00
Martin Vogel a71a65f68e Fix smoke tests: CLANG64 runtime for Windows, debug stderr on error
1. smoke-windows: Use CLANG64 (not UCRT64) so runtime matches the
   build environment. Binary built with CLANG64 needs CLANG64 DLLs.
2. smoke-unix: Add fail-fast: false so one platform failure doesn't
   cancel all 7 other smoke jobs.
3. smoke-test.sh: Capture and display stderr on indexing failure to
   help debug smoke-unix errors.
4. release.yml: Same CLANG64 smoke fix.
2026-03-19 11:31:12 +01:00
Martin Vogel 0e9a47177b Fix Windows build: add zip pkg, portable embed (od replaces xxd)
1. Add zip to MSYS2 build packages (both dry-run and release).
2. embed-frontend.sh: replace xxd with od+sed for hex dump — xxd
   requires vim which isn't in MSYS2 CLANG64 by default.
3. embed-frontend.sh: flip IS_MACOS→IS_LINUX — Linux gets ld -r -b
   binary (ELF-only), everything else (macOS, Windows) gets the
   portable C-array approach via od.
4. release.yml: same Windows archive fix (msys2 shell + .exe detect).
2026-03-19 10:59:14 +01:00
Martin Vogel 89dd3bb7c6 Add skip_tests/skip_builds flags, fix build-stage failures
1. dry-run.yml: Add skip_tests and skip_builds workflow_dispatch inputs
   for faster iteration. Build jobs use always() to run even when tests
   are skipped.

2. Windows archive: Switch from PowerShell Copy-Item to MSYS2 shell
   with .exe extension detection. MSYS2 Clang produces .exe suffix
   that Copy-Item didn't account for.

3. Linux embed: Use absolute path for ld output when cd'd into dist
   directory. Relative path build/c/embedded/*.o was invalid from
   inside graph-ui/dist/.

4. release.yml: Same Windows archive fix as dry-run.
2026-03-19 10:43:32 +01:00
Martin Vogel 0f83f08653 Auto-detect WIN32_LIBS in Makefile, remove shell quoting entirely 2026-03-19 00:00:19 +01:00
Martin Vogel b5f14f115d Fix WIN32_LIBS quoting via env vars, add skip_lint to dry-run
- Use env: block instead of shell quoting for WIN32_LIBS in CI
- Forward WIN32_LIBS from environment in test.sh and build.sh
- Add skip_lint input to dry-run workflow for faster iteration
2026-03-18 23:35:35 +01:00
Martin Vogel 30505ec596 Switch Windows CI to CLANG64 for ASan/UBSan support
MinGW GCC does not ship ASan runtime on Windows. MSYS2 CLANG64
provides full sanitizer support via compiler-rt. All platforms
now run tests with ASan + UBSan — no exceptions.
2026-03-18 21:21:30 +01:00
Martin Vogel c8bdf924e5 Fix production build errors, add build step to Docker test infra
- Fix GCC -O2 warnings: calloc for cf (maybe-uninitialized),
  suppress stringop-truncation/alloc-size-larger-than (false positives),
  guard louvain against negative node_count
- Default compiler: cc on macOS, gcc on Linux/Windows (fixes gcc-14
  not found on MSYS2)
- Docker test infra now runs BOTH test (ASan) and build (-O2 -Werror)
2026-03-18 17:15:46 +01:00
Martin Vogel 8f225a37dd Use cc (Apple Clang) on macOS, gcc on Linux — unified CI/local parity
- Add scripts/env.sh: detects true hardware arch (even under Rosetta),
  verifies compiler supports target arch, adds arch prefix on macOS
- macOS uses cc/c++ everywhere (tests + builds) — ASan works natively
- Linux uses gcc/g++ everywhere — full sanitizer support
- Remove broken CC ?= gcc-14 from Makefile (GNU Make built-in overrides it)
- Scripts accept --arch flag and CC=/CXX= overrides
2026-03-18 13:08:33 +01:00
Martin Vogel fd1640ec29 Add build scripts, fix GCC warnings, unify CI workflows
- Add scripts/clean.sh, test.sh, build.sh, lint.sh as single source
  of truth for local and CI builds (always clean, always parallel)
- Fix -Wmissing-braces: replace {{0}} with memset for struct arrays
- Fix -Wrestrict: use intermediate buffer for same-struct snprintf
- Update dry-run.yml and release.yml to use the new scripts
2026-03-18 12:31:53 +01:00
Martin Vogel ce96ecc085 Add comprehensive smoke test: version + index + search + trace + folder integrity 2026-03-17 22:25:26 +01:00
Martin Vogel 18fa9979ee 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
2026-03-17 22:05:57 +01:00
Martin Vogel 6f0910278b Remove all Go code — project is now pure C
Delete Go MCP server, CGo bridges, Go pipeline, store, tools, watcher,
cypher engine, language specs, and all Go tests. Replace Go pre-commit
hook with C-only linting (clang-tidy, cppcheck, clang-format, tests).
Tree-sitter extraction engine (internal/cbm/*.c) retained for C pipeline.
2026-03-15 20:32:19 +01:00
Martin Vogel 94a9a92f83 Add C-native pipeline with blocking clang-tidy, cppcheck, clang-format linting
Complete C implementation of the indexing pipeline (src/), parallel worker
pool, graph buffer with merge support, SQLite writer, and 1893-test suite.

Linter setup: zero warnings from clang-tidy (all checks enabled, no NOLINT
suppressions), cppcheck, and clang-format. All issues fixed at source —
proper headers for external linkage, GROW_ARRAY macro restructured to
eliminate type parameter, null-deref paths guarded, named intermediates
for suspicious-argument checks.
2026-03-15 19:26:12 +01:00
Martin Vogel bd6bbc2ab1 Add Go LSP hybrid type resolver, config store, and supporting infrastructure
- Go LSP cross-file type resolution engine (internal/cbm/lsp/) with C-based
  type registry, scope tracking, and Go stdlib data (30K+ definitions)
- lsp_bridge.go: CrossFileDef struct and RunGoLSPCrossFile CGo bridge
- config.go: persistent ConfigStore (SQLite) for auto_index, mem_limit settings
- CLI config subcommand for get/set/list/delete operations
- Store: edge batch upsert, project config columns, goleak test harness
- Pipeline: prefetch parallelism, resolver improvements, memleak tests
- CI: dry-run workflow improvements, vendor-grammar.sh enhancements
2026-03-12 13:26:13 +01:00
Chitral Verma d248e7348f Fix binary move command in setup script (#16) 2026-03-06 21:19:38 +01:00
Martin Vogel 5b25f885d7 Add smoke-test.sh for CI binary validation 2026-03-06 18:27:51 +01:00
Martin Vogel 05a35ac9b1 v0.5.1: Fix C/C++/CUDA/GLSL function extraction, add config linker and tests
- Fix extract_defs.c declarator chain traversal for C-family function_definition
  nodes (off-by-one in field name length, missing depth traversal)
- Add resolve_func_name() support for CommonLisp defun, Makefile rule, VimScript,
  Julia, Elm value_declaration, Groovy field_function methods
- Add config linker pipeline: 3 strategies linking config keys to code symbols,
  dependency manifest entries to imports, and config file path references
- Add regression tests (~150 cases across 50+ languages), language failure tests,
  and config extraction tests
- Refactor discover.go, configures.go, configlink_strategies.go to reduce
  cognitive complexity (extract helpers for gocognit compliance)
- Fix Louvain community detection: use map lookup instead of O(N) scan
2026-03-06 17:50:18 +01:00
Martin Vogel 59d40d4035 v0.5: CBM tree-sitter engine, 59 vendored language grammars
- Replace Go-binding tree-sitter with vendored C grammars compiled via
  CGo (internal/cbm/); eliminates all Go module/linker fragility
- Add 32 new languages: Clojure, CMake, COBOL, Common Lisp, CUDA, Elm,
  Emacs Lisp, Fortran, F#, GLSL, GraphQL, INI, JSON, Julia, Makefile,
  Markdown, Meson, Nix, Protobuf, Svelte, Verilog, Vim Script, Vue, XML
  (plus C, C#, Erlang, SQL, YAML quality improvements)
- Adaptive worker concurrency and mmap prefetch for faster indexing
- Graph buffer: batched SQLite writes for 3-5x throughput improvement
- Fix cancellation test: use 50ms timeout (pipeline now indexes 212-file
  Erlang repo in ~400ms, well under the old 2s deadline)
- Fix isTestFunction: add "Test" prefix for C#, "test" prefix for Scala
2026-03-05 22:39:01 +01:00
Martin Vogel 02bc3b7352 Release v0.3.0: 25 languages, install/update CLI, skills, benchmark
Language expansion (13 → 25):
  Add Ruby, C, Bash, Zig, Elixir, Haskell, OCaml, HTML, CSS, YAML,
  TOML, HCL with tree-sitter grammars and language specs.
  Restore Erlang and SQL with extraction fixes.

CLI install/update/uninstall commands:
  Auto-detect Claude Code and Codex CLI, register MCP server,
  install task-specific skills, self-update with SHA-256 verification.

Embedded skills (4):
  exploring, tracing, quality, reference — auto-trigger in Claude Code
  for graph-first code discovery.

Pipeline improvements:
  Docstring extraction, enrichment pass for params/returns/complexity,
  graceful context cancellation, improved test detection.

35-language benchmark (BENCHMARK.md):
  12 questions × 35 repos, 91.8% overall score, Linux kernel stress
  test (20K nodes, zero timeouts). Replaces old benchmark artifacts.
2026-03-01 18:01:52 +01:00
Martin Vogel b86738acfb Fix setup.sh: Apple Silicon detection under Rosetta and tmpdir cleanup
- detect_platform() now checks hw.optional.arm64 sysctl on macOS to
  pick the arm64 binary even when bash runs under Rosetta (uname -m
  reports x86_64 in that case)
- Move tmpdir to a global CLEANUP_DIR so the EXIT trap does not hit
  an unbound variable error from set -u after the function returns
2026-02-25 10:19:32 +01:00
Martin Vogel 3c6ad62ed0 Add cross-platform setup scripts and CI release workflow
- GitHub Actions workflow builds native binaries for 5 platforms:
  darwin-arm64, darwin-amd64, linux-amd64, linux-arm64, windows-amd64
- Windows build uses MSYS2 UCRT64 toolchain for CGO compatibility
- setup.sh: macOS/Linux installer (binary download or --from-source)
- setup-windows.ps1: Windows installer (native .exe or -FromSource via WSL)
- Both scripts offer interactive Claude Code MCP auto-configuration
- Release includes checksums.txt with SHA-256 hashes
- PS5.1-compatible JSON handling (no -AsHashtable dependency)
2026-02-25 10:07:45 +01:00