mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-10 09:13:53 +08:00
detect_collect_seeds treated every definition in a changed file as a BFS seed, regardless of which lines actually changed. A one-line edit inside a single method seeded every other definition in the file too, producing an impact report an order of magnitude larger than what the edit actually touched. Fetch `git diff --unified=0` hunks (cbm_parse_hunks already existed in pass_gitdiff.c but had no caller) alongside the existing file list, and scope seeds to definitions whose line range overlaps a hunk. Any failure fetching hunks (new/untracked files, a transient git error) falls back to the previous whole-file behavior, so this is a precision improvement with no new failure mode. Verified on microsoft/qlib (an unrelated third-party repo): a same- line-count edit inside one method now seeds 2 symbols (the method + its containing class) instead of 25 (every definition in the 24-def file), matching the equivalent output of a different code-graph tool (GitNexus) on the identical scenario. Reproduced on a second file with a different definition count (42 defs -> seeds 43 before the fix, 2 after) to rule out coincidence. cbm_changed_hunk_t / cbm_parse_hunks move from pipeline_internal.h (explicitly not a public header) to pipeline.h, since detect_changes now needs them from src/mcp/mcp.c. cbm_detect_node_in_hunks is exposed non-static via mcp_internal.h, matching this file's existing white-box test-hook pattern, so the overlap logic has a direct unit test independent of the git/subprocess/index plumbing around it. Fixes #1363 Signed-off-by: lishixiang <lishixiang@gmail.com>