Files
codebase-memory-mcp/scripts
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
..